Research portable Memory game | Исследовать портируемую игру Память
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

79 wiersze
1.8KB

  1. from gui_aux import *
  2. from gui_TextureDescription import *
  3. from llm import *
  4. from memory_Context import *
  5. # Generate textures descriptions
  6. #
  7. # Conditions:
  8. # 1. tileImage or tileImageCount or tileImageHeight or tileImageWidth has just changed
  9. # 2. tileImage, tileImageCount, tileImageHeight, tileImageWidth are not empty
  10. @llm_by_value
  11. def gui_generateTextureDescriptions(
  12. c: memory_Context
  13. ) -> memory_Context:
  14. if (
  15. c.recentField == "tileImage" or
  16. c.recentField == "tileImageCount" or
  17. c.recentField == "tileImageHeight" or
  18. c.recentField == "tileImageWidth"
  19. ):
  20. tds: list[gui_TextureDescription] = []
  21. for id in range(0, c.tileImageCount):
  22. td = gui_createTextureDescription()
  23. td.fileName = c.tileImage
  24. td.height = c.tileImageHeight
  25. td.width = c.tileImageWidth
  26. td.x = id * c.tileImageWidth
  27. td.y = 0
  28. tds.append(td)
  29. #}
  30. c.textureDescriptions = tds
  31. c.recentField = "textureDescriptions"
  32. return c
  33. #}
  34. c.recentField = "none"
  35. return c
  36. #}
  37. # Generate tile positions
  38. #
  39. # Conditions:
  40. # 1. cellSize, playField, windowHeight, or windowWidth has changed and none of them is zero
  41. @llm_by_value
  42. def gui_generateTilePositions(
  43. c: memory_Context
  44. ) -> memory_Context:
  45. if (
  46. (
  47. c.recentField != "cellPositions" and
  48. c.recentField != "cellSize" and
  49. c.recentField != "playfieldSize" and
  50. c.recentField != "windowHeight" and
  51. c.recentField != "windowWidth"
  52. ) or
  53. (
  54. len(c.cellPositions) == 0 or
  55. c.cellSize == 0 or
  56. c.playfieldSize == 0 or
  57. c.windowHeight == 0 or
  58. c.windowWidth == 0
  59. )
  60. ):
  61. c.recentField = "none"
  62. return c
  63. #}
  64. ps = []
  65. for i in range(0, len(c.cellPositions)):
  66. p = gui_aux_cellScreenPosition(c, c.cellPositions[i])
  67. ps.append(p)
  68. #}
  69. c.tilePositions = ps
  70. c.recentField = "tilePositions"
  71. return c
  72. #}