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.

69 lines
1.7KB

  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.GRAY)
  9. arcade.set_background_color(arcade.color.WHITE)
  10. self.all_sprites = arcade.SpriteList()
  11. # # Animated begin button.
  12. # player = arcade.AnimatedTimeBasedSprite()
  13. # for i in range(2):
  14. # tex = arcade.load_texture("res/buttons_begin.png", x = i*350, y = 0, width = 350, height = 100)
  15. # player.append_texture(tex)
  16. # #player.color = arcade.color.BLUE
  17. # a = arcade.sprite.AnimationKeyframe(i, 700, tex)
  18. # player.frames.append(a)
  19. # player.center_x = 300
  20. # player.center_y = 200
  21. # self.all_sprites.append(player)
  22. positions = [
  23. [9, 1],
  24. [14, 1],
  25. [19, 1],
  26. [24, 1],
  27. [9, 7],
  28. [14, 7],
  29. [19, 7],
  30. [24, 7],
  31. [9, 13],
  32. [14, 13],
  33. [19, 13],
  34. [24, 13],
  35. [9, 19],
  36. [14, 19],
  37. [19, 19],
  38. [24, 19],
  39. ]
  40. add_tiles(self.all_sprites, positions)
  41. def on_draw(self):
  42. arcade.start_render()
  43. #arcade.draw_circle_filled(400, 300, 15, arcade.color.BLUE)
  44. self.all_sprites.draw()
  45. def on_update(self, delta):
  46. self.all_sprites.update_animation()
  47. def add_tiles(sprites, positions):
  48. for p in positions:
  49. tile = arcade.AnimatedTimeBasedSprite()
  50. for i in range(2):
  51. tex = arcade.load_texture("res/tiles_0.png", x = i*75, y = 0, width = 75, height = 100)
  52. tile.append_texture(tex)
  53. a = arcade.sprite.AnimationKeyframe(i, 700, tex)
  54. tile.frames.append(a)
  55. tile.center_x = CELL * 2 + p[0] * CELL
  56. tile.center_y = HEIGHT - CELL * 2 - p[1] * CELL
  57. sprites.append(tile)