Research portable Memory game | Исследовать портируемую игру Память
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

293 Zeilen
6.4KB

  1. import arcade
  2. from gui_aux import *
  3. from desktop_Platform import *
  4. def desktop_createDesc(p):
  5. p.desc = arcade.Sprite()
  6. p.descSprites.append(p.desc)
  7. p.desc.texture = p.descTextures[0]
  8. # Position.
  9. pos = gui_aux_cellScreenPosition(p.c, p.c.descPosition)
  10. p.desc.left = pos[0]
  11. p.desc.top = pos[1]
  12. # Invisible by default.
  13. p.desc.visible = False
  14. #}
  15. def desktop_createDeselectedTiles(p):
  16. for (id, pos) in enumerate(p.c.tilePositions):
  17. tile = arcade.AnimatedTimeBasedSprite()
  18. p.deselectedTiles.append(tile)
  19. p.deselectedSprites.append(tile)
  20. tile.guid = id
  21. tile.texture = p.textures[0]
  22. # Animation between two textures.
  23. a1 = arcade.sprite.AnimationKeyframe(0, 700, p.textures[0])
  24. a2 = arcade.sprite.AnimationKeyframe(1, 700, p.textures[1])
  25. tile.frames.append(a1)
  26. tile.frames.append(a2)
  27. # Position.
  28. tile.left = pos[0]
  29. tile.top = pos[1]
  30. #}
  31. #}
  32. def desktop_createSelectedTiles(p):
  33. for (id, pos) in enumerate(p.c.tilePositions):
  34. tile = arcade.Sprite()
  35. p.selectedTiles.append(tile)
  36. p.selectedSprites.append(tile)
  37. tile.guid = id
  38. tile.texture = p.textures[2 + p.c.playfieldItems[id]]
  39. # Position.
  40. tile.left = pos[0]
  41. tile.top = pos[1]
  42. # Invisible by default.
  43. tile.visible = False
  44. #}
  45. #}
  46. def desktop_createSplash(p):
  47. p.splash = arcade.Sprite()
  48. p.splashSprites.append(p.splash)
  49. p.splash.texture = p.splashTextures[0]
  50. # Position.
  51. pos = gui_aux_cellScreenPosition(p.c, [0, 0])
  52. p.splash.left = pos[0]
  53. p.splash.top = pos[1]
  54. #}
  55. def desktop_createTitle(p):
  56. p.title = arcade.Sprite()
  57. p.titleSprites.append(p.title)
  58. p.title.texture = p.titleTextures[0]
  59. # Position.
  60. pos = gui_aux_cellScreenPosition(p.c, p.c.titlePosition)
  61. p.title.left = pos[0]
  62. p.title.top = pos[1]
  63. # Invisible by default.
  64. p.title.visible = False
  65. #}
  66. # Deselect mismatched tiles
  67. #
  68. # Conditions:
  69. # 1. Time to deselect mismatched items
  70. def desktop_deselectMismatchedTiles(p):
  71. if (
  72. p.c.recentField == "deselectMismatchedTiles"
  73. ):
  74. for id in p.c.mismatchedItems:
  75. p.deselectedTiles[id].visible = True
  76. p.selectedTiles[id].visible = False
  77. #}
  78. #}
  79. #}
  80. # Display description for the first selected tile
  81. #
  82. # Conditions:
  83. # 1. tile has just been selected and it's the first one in pair
  84. def desktop_displayDesc(p):
  85. if (
  86. p.c.recentField == "selectedId" and
  87. (
  88. len(p.c.selectedItems) == 0 or
  89. len(p.c.selectedItems) == 2
  90. )
  91. ):
  92. gid = p.c.playfieldItems[p.c.selectedId]
  93. p.desc.texture = p.descTextures[gid]
  94. p.desc.visible = True
  95. #}
  96. #}
  97. # Hide deselected tile and show selected one
  98. #
  99. # Conditions:
  100. # 1. tile has just been selected
  101. def desktop_displaySelectedTile(p):
  102. if (
  103. p.c.recentField == "selectedId"
  104. ):
  105. id = p.c.selectedId
  106. p.deselectedTiles[id].visible = False
  107. p.selectedTiles[id].visible = True
  108. #}
  109. #}
  110. # Display title for the first selected tile
  111. #
  112. # Conditions:
  113. # 1. tile has just been selected and it's the first one in pair
  114. def desktop_displayTitle(p):
  115. if (
  116. p.c.recentField == "selectedId" and
  117. (
  118. len(p.c.selectedItems) == 0 or
  119. len(p.c.selectedItems) == 2
  120. )
  121. ):
  122. gid = p.c.playfieldItems[p.c.selectedId]
  123. p.title.texture = p.titleTextures[gid]
  124. p.title.visible = True
  125. #}
  126. #}
  127. # Hide beginning splash screen
  128. #
  129. # Conditions:
  130. # 1. Time to hide
  131. def desktop_hideBeginningSplashScreen(p):
  132. if (
  133. p.c.recentField == "hideBeginningSplashScreen"
  134. ):
  135. p.splash.visible = False
  136. #}
  137. #}
  138. # Hide description
  139. #
  140. # Conditions:
  141. # 1. tiles has been mismatched or timed out to to hide after matching
  142. def desktop_hideDesc(p):
  143. if (
  144. p.c.recentField == "hideMatchingTiles" or
  145. p.c.recentField == "mismatchedItems"
  146. ):
  147. p.desc.visible = False
  148. #}
  149. #}
  150. # Hide matching tiles
  151. #
  152. # Conditions:
  153. # 1. Time to hide matching items
  154. def desktop_hideMatchingTiles(p):
  155. if (
  156. p.c.recentField == "hideMatchingTiles"
  157. ):
  158. for id in p.c.selectedItems:
  159. p.deselectedTiles[id].visible = False
  160. p.selectedTiles[id].visible = False
  161. #}
  162. #}
  163. #}
  164. # Hide title
  165. #
  166. # Conditions:
  167. # 1. tiles has been mismatched or timed out to to hide after matching
  168. def desktop_hideTitle(p):
  169. if (
  170. p.c.recentField == "hideMatchingTiles" or
  171. p.c.recentField == "mismatchedItems"
  172. ):
  173. p.title.visible = False
  174. #}
  175. #}
  176. # Load description textures
  177. def desktop_loadDescTextures(p):
  178. texs = []
  179. for (id, td) in enumerate(p.c.descTextureDescriptions):
  180. tex = arcade.load_texture(
  181. td.fileName,
  182. x = td.x,
  183. y = td.y,
  184. width = td.width,
  185. height = td.height
  186. )
  187. texs.append(tex)
  188. #}
  189. p.descTextures = texs
  190. #}
  191. # Load beginning and ending textures
  192. def desktop_loadSplashTextures(p):
  193. texs = []
  194. for (id, td) in enumerate(p.c.splashTextureDescriptions):
  195. tex = arcade.load_texture(
  196. td.fileName,
  197. x = td.x,
  198. y = td.y,
  199. width = td.width,
  200. height = td.height
  201. )
  202. texs.append(tex)
  203. print(f"desktop_loadST: '{tex}'")
  204. #}
  205. p.splashTextures = texs
  206. #}
  207. # Load tile textures
  208. def desktop_loadTextures(p):
  209. texs = []
  210. for (id, td) in enumerate(p.c.textureDescriptions):
  211. tex = arcade.load_texture(
  212. td.fileName,
  213. x = td.x,
  214. y = td.y,
  215. width = td.width,
  216. height = td.height
  217. )
  218. texs.append(tex)
  219. #}
  220. p.textures = texs
  221. #}
  222. # Load tiTLe textures
  223. def desktop_loadTitleTextures(p):
  224. texs = []
  225. for (id, td) in enumerate(p.c.titleTextureDescriptions):
  226. tex = arcade.load_texture(
  227. td.fileName,
  228. x = td.x,
  229. y = td.y,
  230. width = td.width,
  231. height = td.height
  232. )
  233. texs.append(tex)
  234. #}
  235. p.titleTextures = texs
  236. #}
  237. # Postpone deselection of mismatched tiles for better UX
  238. #
  239. # Conditions:
  240. # 1. a pair of tiles has been mismatched
  241. def desktop_scheduleDeselectionOfMismatchedTiles(p):
  242. if (
  243. p.c.recentField == "mismatchedItems"
  244. ):
  245. p.sequentialTimer.schedule("deselectMismatchedTiles", True, p.c.deselectMismatchedTilesDelay)
  246. #}
  247. #}
  248. # Postpone hiding of matching tiles for better UX
  249. #
  250. # Conditions:
  251. # 1. a pair of tiles has been matched
  252. def desktop_scheduleHidingOfMatchingTiles(p):
  253. if (
  254. p.c.recentField == "hiddenItems"
  255. ):
  256. p.sequentialTimer.schedule("hideMatchingTiles", True, p.c.hideMatchingTilesDelay)
  257. #}
  258. #}
  259. # Postpone hiding of the beginning splash screen
  260. #
  261. # Conditions:
  262. # 1. just launched the game
  263. def desktop_scheduleHidingOfBeginningSplashScreen(p):
  264. if (
  265. p.c.recentField == "didLaunch"
  266. ):
  267. p.sequentialTimer.schedule("hideBeginningSplashScreen", True, p.c.splashBeginTimeout)
  268. #}
  269. #}