flame.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import json
  2. import pygame
  3. from client_local.file_loader.fileLoader import load_json, load_png
  4. FLAME_JSON_ROOT = "game/frame/flame/"
  5. FLAME_JSON_FILE = "flame.json"
  6. FLAME_IMG_ROOT = "res/img/flame/"
  7. ORIENTATIONS = ("FLAME_C", "FLAME_R", "FLAME_U", "FLAME_L", "FLAME_D")
  8. flames = {}
  9. j = load_json(FLAME_JSON_ROOT + '/' + FLAME_JSON_FILE)
  10. flame_seq = j["FLAME_SEQ"]
  11. def get_flame(orientation):
  12. if orientation not in flames.keys():
  13. flames[orientation] = list()
  14. flame_json = load_json(FLAME_JSON_ROOT + '/' + FLAME_JSON_FILE)
  15. root = flame_json[orientation]
  16. size = len(root["IMG"])
  17. for i in range(size):
  18. img = load_png(FLAME_IMG_ROOT + '/' + root["IMG"][i])
  19. # img = pygame.image.load(FLAME_IMG_ROOT + '/' + root["IMG"][i]).convert_alpha()
  20. cx = root["CX"][i]
  21. cy = root["CY"][i]
  22. a_flame = Frame(img, cx, cy)
  23. flames[orientation].append(a_flame)
  24. return flames[orientation]
  25. class Frame:
  26. def __init__(self, image: pygame.Surface, cx, cy):
  27. self.image = image
  28. self.cx = cx
  29. self.cy = cy