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.

94 line
2.0KB

  1. import arcade
  2. from desktop_Platform import *
  3. def desktop_loadTextures(p):
  4. texs = []
  5. for (id, td) in enumerate(p.c.textureDescriptions):
  6. tex = arcade.load_texture(
  7. td.fileName,
  8. x = td.x,
  9. y = td.y,
  10. width = td.width,
  11. height = td.height
  12. )
  13. texs.append(tex)
  14. #}
  15. p.textures = texs
  16. #}
  17. def desktop_createDeselectedTiles(p):
  18. for (id, pos) in enumerate(p.c.tilePositions):
  19. tile = arcade.AnimatedTimeBasedSprite()
  20. p.deselectedTiles.append(tile)
  21. p.sprites.append(tile)
  22. tile.guid = id
  23. tile.texture = p.textures[0]
  24. # Animation between two textures.
  25. a1 = arcade.sprite.AnimationKeyframe(0, 700, p.textures[0])
  26. a2 = arcade.sprite.AnimationKeyframe(1, 700, p.textures[1])
  27. tile.frames.append(a1)
  28. tile.frames.append(a2)
  29. # Position.
  30. tile.left = pos[0]
  31. tile.top = pos[1]
  32. #}
  33. #}
  34. def desktop_createSelectedTiles(p):
  35. for (id, pos) in enumerate(p.c.tilePositions):
  36. tile = arcade.Sprite()
  37. p.selectedTiles.append(tile)
  38. p.sprites.append(tile)
  39. tile.guid = id
  40. tile.texture = p.textures[2]
  41. # Position.
  42. tile.left = pos[0]
  43. tile.top = pos[1]
  44. # Invisible by default.
  45. tile.visible = False
  46. #}
  47. #}
  48. # Hide deselected tile and show selected one
  49. #
  50. # Conditions:
  51. # 1. tile has just been selected
  52. def desktop_displaySelectedTile(p):
  53. if (
  54. p.c.recentField == "selectedId"
  55. ):
  56. id = p.c.selectedId
  57. p.deselectedTiles[id].visible = False
  58. p.selectedTiles[id].visible = True
  59. #}
  60. #}
  61. # Hide matching tiles
  62. #
  63. # Conditions:
  64. # 1. Time to hide matching items
  65. def desktop_hideMatchingTiles(p):
  66. if (
  67. p.c.recentField == "hideMatchingTiles"
  68. ):
  69. for id in p.c.hiddenItems:
  70. p.deselectedTiles[id].visible = False
  71. p.selectedTiles[id].visible = False
  72. #}
  73. #}
  74. #}
  75. # Postpone hiding of matching tiles for better UX
  76. #
  77. # Conditions:
  78. # 1. a pair of tiles has been matched
  79. def desktop_scheduleHidingOfMatchingTiles(p):
  80. if (
  81. p.c.recentField == "hiddenItems"
  82. ):
  83. p.sequentialTimer.schedule("hideMatchingTiles", True, p.c.hideMatchingTilesDelay)
  84. #}
  85. #}