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.

81 line
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 != "cellSize" and
  48. c.recentField != "playfieldSize" and
  49. c.recentField != "windowHeight" and
  50. c.recentField != "windowWidth"
  51. ) or
  52. (
  53. c.cellSize == 0 or
  54. c.playfieldSize == 0 or
  55. c.windowHeight == 0 or
  56. c.windowWidth == 0
  57. )
  58. ):
  59. c.recentField = "none"
  60. return c
  61. #}
  62. positions = gui_aux_cellPositions(c.playfieldSize)
  63. ps = []
  64. for i in range(0, len(positions)):
  65. p = positions[i]
  66. x = p[0] * c.cellSize
  67. y = c.windowHeight - p[1] * c.cellSize
  68. ps.append([x, y])
  69. #}
  70. c.tilePositions = ps
  71. c.recentField = "tilePositions"
  72. return c
  73. #}