Research portable Memory game | Исследовать портируемую игру Память
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

95 lines
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. # Postpone hiding of matching tiles for better UX
  62. #
  63. # Conditions:
  64. # 1. a pair of tiles has been matched
  65. def desktop_scheduleHidingOfMatchingTiles(p):
  66. if (
  67. p.c.recentField == "hiddenItems"
  68. ):
  69. p.sequentialTimer.schedule("hideMatchingTiles", True, 500)
  70. #}
  71. #}
  72. # Hide matching tiles
  73. # TODO: Rearrange the position of the func
  74. #
  75. # Conditions:
  76. # 1. ...
  77. #def desktop_hideMatchingTiles(p):
  78. # if (
  79. # p.c.recentField == "hiddenItems"
  80. # ):
  81. # for id in p.c.hiddenItems:
  82. # p.deselectedTiles[id].visible = False
  83. # p.selectedTiles[id].visible = False
  84. # #}
  85. # #}
  86. ##}