import arcade CELL = 25 HEIGHT = 600 WIDTH = 900 class Window(arcade.Window): def __init__(self): super().__init__(WIDTH, HEIGHT, "OGS Memory") arcade.set_background_color(arcade.color.WHITE) self.all_sprites = arcade.SpriteList() positions = [ [9, 1], [14, 1], [19, 1], [24, 1], [9, 7], [14, 7], [19, 7], [24, 7], [9, 13], [14, 13], [19, 13], [24, 13], [9, 19], [14, 19], [19, 19], [24, 19], ] add_tiles(self.all_sprites, positions) def on_draw(self): arcade.start_render() self.all_sprites.draw() def on_mouse_press(self, x, y, button, key_modifiers): print("click", x, y) sprites = arcade.get_sprites_at_point([x, y], self.all_sprites) if len(sprites) == 1: print("selected: ", sprites[0].guid) def on_update(self, delta): self.all_sprites.update_animation() def add_tiles(sprites, positions): id = 0 for p in positions: tile = arcade.AnimatedTimeBasedSprite() tile.guid = id id += 1 for i in range(2): tex = arcade.load_texture("res/tiles_0.png", x = i*75, y = 0, width = 75, height = 100) tile.append_texture(tex) a = arcade.sprite.AnimationKeyframe(i, 700, tex) tile.frames.append(a) tile.center_x = CELL * 2 + p[0] * CELL tile.center_y = HEIGHT - CELL * 2 - p[1] * CELL sprites.append(tile)