|
@@ -7,22 +7,9 @@ WIDTH = 900 |
|
|
class Window(arcade.Window): |
|
|
class Window(arcade.Window): |
|
|
def __init__(self): |
|
|
def __init__(self): |
|
|
super().__init__(WIDTH, HEIGHT, "OGS Memory") |
|
|
super().__init__(WIDTH, HEIGHT, "OGS Memory") |
|
|
#arcade.set_background_color(arcade.color.GRAY) |
|
|
|
|
|
arcade.set_background_color(arcade.color.WHITE) |
|
|
arcade.set_background_color(arcade.color.WHITE) |
|
|
self.all_sprites = arcade.SpriteList() |
|
|
self.all_sprites = arcade.SpriteList() |
|
|
|
|
|
|
|
|
# # Animated begin button. |
|
|
|
|
|
# player = arcade.AnimatedTimeBasedSprite() |
|
|
|
|
|
# for i in range(2): |
|
|
|
|
|
# tex = arcade.load_texture("res/buttons_begin.png", x = i*350, y = 0, width = 350, height = 100) |
|
|
|
|
|
# player.append_texture(tex) |
|
|
|
|
|
# #player.color = arcade.color.BLUE |
|
|
|
|
|
# a = arcade.sprite.AnimationKeyframe(i, 700, tex) |
|
|
|
|
|
# player.frames.append(a) |
|
|
|
|
|
# player.center_x = 300 |
|
|
|
|
|
# player.center_y = 200 |
|
|
|
|
|
# self.all_sprites.append(player) |
|
|
|
|
|
|
|
|
|
|
|
positions = [ |
|
|
positions = [ |
|
|
[9, 1], |
|
|
[9, 1], |
|
|
[14, 1], |
|
|
[14, 1], |
|
@@ -49,15 +36,23 @@ class Window(arcade.Window): |
|
|
|
|
|
|
|
|
def on_draw(self): |
|
|
def on_draw(self): |
|
|
arcade.start_render() |
|
|
arcade.start_render() |
|
|
#arcade.draw_circle_filled(400, 300, 15, arcade.color.BLUE) |
|
|
|
|
|
self.all_sprites.draw() |
|
|
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): |
|
|
def on_update(self, delta): |
|
|
self.all_sprites.update_animation() |
|
|
self.all_sprites.update_animation() |
|
|
|
|
|
|
|
|
def add_tiles(sprites, positions): |
|
|
def add_tiles(sprites, positions): |
|
|
|
|
|
id = 0 |
|
|
for p in positions: |
|
|
for p in positions: |
|
|
tile = arcade.AnimatedTimeBasedSprite() |
|
|
tile = arcade.AnimatedTimeBasedSprite() |
|
|
|
|
|
tile.guid = id |
|
|
|
|
|
id += 1 |
|
|
for i in range(2): |
|
|
for i in range(2): |
|
|
tex = arcade.load_texture("res/tiles_0.png", x = i*75, y = 0, width = 75, height = 100) |
|
|
tex = arcade.load_texture("res/tiles_0.png", x = i*75, y = 0, width = 75, height = 100) |
|
|
tile.append_texture(tex) |
|
|
tile.append_texture(tex) |
|
|