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.

desktop.py 2.7KB

6 months ago
6 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import arcade
  2. from desktop_Platform import *
  3. def desktop_createDeselectedTiles(p):
  4. for (id, pos) in enumerate(p.c.tilePositions):
  5. tile = arcade.AnimatedTimeBasedSprite()
  6. p.deselectedTiles.append(tile)
  7. p.sprites.append(tile)
  8. tile.guid = id
  9. tile.texture = p.textures[0]
  10. # Animation between two textures.
  11. a1 = arcade.sprite.AnimationKeyframe(0, 700, p.textures[0])
  12. a2 = arcade.sprite.AnimationKeyframe(1, 700, p.textures[1])
  13. tile.frames.append(a1)
  14. tile.frames.append(a2)
  15. # Position.
  16. tile.left = pos[0]
  17. tile.top = pos[1]
  18. #}
  19. #}
  20. def desktop_createSelectedTiles(p):
  21. for (id, pos) in enumerate(p.c.tilePositions):
  22. tile = arcade.Sprite()
  23. p.selectedTiles.append(tile)
  24. p.sprites.append(tile)
  25. tile.guid = id
  26. tile.texture = p.textures[2 + id]
  27. # Position.
  28. tile.left = pos[0]
  29. tile.top = pos[1]
  30. # Invisible by default.
  31. tile.visible = False
  32. #}
  33. #}
  34. # Deselect mismatched tiles
  35. #
  36. # Conditions:
  37. # 1. Time to deselect mismatched items
  38. def desktop_deselectMismatchedTiles(p):
  39. if (
  40. p.c.recentField == "deselectMismatchedTiles"
  41. ):
  42. for id in p.c.mismatchedItems:
  43. p.deselectedTiles[id].visible = True
  44. p.selectedTiles[id].visible = False
  45. #}
  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.selectedItems:
  70. p.deselectedTiles[id].visible = False
  71. p.selectedTiles[id].visible = False
  72. #}
  73. #}
  74. #}
  75. def desktop_loadTextures(p):
  76. texs = []
  77. for (id, td) in enumerate(p.c.textureDescriptions):
  78. tex = arcade.load_texture(
  79. td.fileName,
  80. x = td.x,
  81. y = td.y,
  82. width = td.width,
  83. height = td.height
  84. )
  85. texs.append(tex)
  86. #}
  87. p.textures = texs
  88. #}
  89. # Postpone deselection of mismatched tiles for better UX
  90. #
  91. # Conditions:
  92. # 1. a pair of tiles has been mismatched
  93. def desktop_scheduleDeselectionOfMismatchedTiles(p):
  94. if (
  95. p.c.recentField == "mismatchedItems"
  96. ):
  97. p.sequentialTimer.schedule("deselectMismatchedTiles", True, p.c.deselectMismatchedTilesDelay)
  98. #}
  99. #}
  100. # Postpone hiding of matching tiles for better UX
  101. #
  102. # Conditions:
  103. # 1. a pair of tiles has been matched
  104. def desktop_scheduleHidingOfMatchingTiles(p):
  105. if (
  106. p.c.recentField == "hiddenItems"
  107. ):
  108. p.sequentialTimer.schedule("hideMatchingTiles", True, p.c.hideMatchingTilesDelay)
  109. #}
  110. #}