# decompyle3 version 3.9.3 # Python bytecode version base 3.7.0 (3394) # Decompiled from: Python 3.13.1 (tags/v3.13.1:0671451, Dec 3 2024, 19:06:28) [MSC v.1942 64 bit (AMD64)] # Embedded file name: game\frame\obstacle.py import json, pygame from pathlib import Path from game.frame.frame import Frame OBSTACLE_FRAME_ROOT = "game/frame/obstacle/" OBSTACLE_IMG_ROOT = "res/img/mapElem/" obstacles = {} def get_obstacle(type, name): if type not in obstacles.keys(): obstacles[type] = dict() if name not in obstacles[type].keys(): obstacles[type][name] = load_obstacle(type, name) return obstacles[type][name] def load_obstacle(type, name): an_obstacle = {} path = Path(OBSTACLE_FRAME_ROOT) / type / (name + ".json") if not path.is_file(): path = Path("game/frame/obstacles") / type / (name + ".json") with path.open(encoding="utf-8-sig") as f: obstacle_json = json.load(f) an_obstacle["TYPE"] = type an_obstacle["NAME"] = name an_obstacle["WIDTH"] = obstacle_json["WIDTH"] an_obstacle["HEIGHT"] = obstacle_json["HEIGHT"] append_obstacle(obstacle_json, an_obstacle, "STAND") return an_obstacle def append_obstacle(obstacle_json, an_obstacle, state: str): if state in obstacle_json: an_obstacle[state] = list() frames = obstacle_json[state] size = len(frames["IMG"]) for i in range(size): img = pygame.image.load(OBSTACLE_IMG_ROOT + obstacle_json["TYPE"] + "/" + frames["IMG"][i]).convert_alpha() cx = frames["CX"][i] cy = frames["CY"][i] an_obstacle[state].append(Frame(img, cx, cy))