Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
5 月之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import arcade
  2. CELL = 25
  3. HEIGHT = 600
  4. WIDTH = 900
  5. class Window(arcade.Window):
  6. def __init__(self):
  7. super().__init__(WIDTH, HEIGHT, "OGS Memory")
  8. arcade.set_background_color(arcade.color.WHITE)
  9. self.all_sprites = arcade.SpriteList()
  10. positions = [
  11. [9, 1],
  12. [14, 1],
  13. [19, 1],
  14. [24, 1],
  15. [9, 7],
  16. [14, 7],
  17. [19, 7],
  18. [24, 7],
  19. [9, 13],
  20. [14, 13],
  21. [19, 13],
  22. [24, 13],
  23. [9, 19],
  24. [14, 19],
  25. [19, 19],
  26. [24, 19],
  27. ]
  28. add_tiles(self.all_sprites, positions)
  29. def on_draw(self):
  30. arcade.start_render()
  31. self.all_sprites.draw()
  32. def on_mouse_press(self, x, y, button, key_modifiers):
  33. print("click", x, y)
  34. sprites = arcade.get_sprites_at_point([x, y], self.all_sprites)
  35. if len(sprites) == 1:
  36. print("selected: ", sprites[0].guid)
  37. def on_update(self, delta):
  38. self.all_sprites.update_animation()
  39. def add_tiles(sprites, positions):
  40. id = 0
  41. for p in positions:
  42. tile = arcade.AnimatedTimeBasedSprite()
  43. tile.guid = id
  44. id += 1
  45. for i in range(2):
  46. tex = arcade.load_texture("res/tiles_0.png", x = i*75, y = 0, width = 75, height = 100)
  47. tile.append_texture(tex)
  48. a = arcade.sprite.AnimationKeyframe(i, 700, tex)
  49. tile.frames.append(a)
  50. tile.center_x = CELL * 2 + p[0] * CELL
  51. tile.center_y = HEIGHT - CELL * 2 - p[1] * CELL
  52. sprites.append(tile)