def draw(self, canvas: draw.Canvas): """ Draws every tile (and its contents) in correct order. """ scr_w, scr_h = canvas.get_size() for y in range(self.h): for x in range(self.w): tile = self.data[x][y] draw_x, draw_y = Tile.to_screen_coords(x, y, tile.z) real_x, real_y = canvas.transform[-1].position(draw_x, draw_y) if real_x < -Tile.tile_w or real_x > scr_w + Tile.tile_w \ or real_y < -Tile.tile_h or real_y > scr_h + Tile.tile_h: continue frame = Tile.image.get_frame(tile.type) canvas.paint(frame, draw_x, draw_y) if tile.object is not None: canvas.save() canvas.translate(draw_x + Tile.tile_w / 2, draw_y + Tile.tile_h / 2) canvas.paint(tile.object) canvas.restore() canvas.set_color_rgb(255, 0, 255)
def paint(self, canvas : draw.Canvas): canvas.set_color_rgb(255, 255, 255) canvas.paint(self.image, -self.image.w/2, -self.image.h)
def paint(self, canvas: draw.Canvas): canvas.set_color_rgb(255, 255, 255) canvas.paint(self.image, -self.image.w / 2, -self.image.h) canvas.paint_rectangle(-1, -1, 2, 2)