您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

desktop_aux.py 1.5KB

3 个月前
3 个月前
3 个月前
3 个月前
3 个月前
3 个月前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import arcade
  2. from cld import *
  3. from desktop_Platform import *
  4. # Convert String config value to Bool or Float if possible
  5. def desktop_aux_convertValue(
  6. value: str
  7. ) -> any:
  8. # Bool.
  9. if (
  10. value == "false"
  11. ):
  12. return False
  13. elif (
  14. value == "true"
  15. ):
  16. return True
  17. # Float.
  18. elif (
  19. cld_isdigit(value)
  20. ):
  21. return float(value)
  22. # String.
  23. return value
  24. def desktop_aux_createPlayerSprite(
  25. p: desktop_Platform,
  26. name: str,
  27. desc: dict[str, str]
  28. ):
  29. sp = arcade.Sprite()
  30. sp.guid = name
  31. texName = desc["texture"]
  32. sp.texture = p.textures[texName]
  33. # Position.
  34. sp.left = float(desc["left"])
  35. sp.top = float(desc["base"])
  36. # Visibility.
  37. sp.visible = True if desc["visible"] == "true" else False
  38. return sp
  39. def desktop_aux_createStaticSprite(
  40. p: desktop_Platform,
  41. name: str,
  42. desc: dict[str, str]
  43. ):
  44. sp = arcade.Sprite()
  45. sp.guid = name
  46. texName = desc["texture"]
  47. sp.texture = p.textures[texName]
  48. # Position.
  49. sp.left = float(desc["left"])
  50. sp.top = float(desc["top"])
  51. # Visibility.
  52. sp.visible = True if desc["visible"] == "true" else False
  53. return sp
  54. def desktop_aux_loadTexture(
  55. resDir: str,
  56. desc: dict[str, str]
  57. ):
  58. path = resDir + "/" + desc["file"]
  59. return arcade.load_texture(
  60. path,
  61. x = float(desc["x"]),
  62. y = float(desc["y"]),
  63. width = float(desc["width"]),
  64. height = float(desc["height"])
  65. )