def on_map_open(file): global RUN try: data = json.load(file) render_list, back, start_pos = map_loader(data, obj_descr) except ValueError: print("Map data not in JSON, try again") else: print(data) finally: file.close()
def __init__(self, json_map, description, width=640, height=480): """Initialize""" """Initialize PyGame""" init() """Set the window Size""" self.width = width self.height = height """Create the Screen""" self.screen = display.set_mode((self.width, self.height)) self.render_list, self.back, self.start_pos = map_loader(json_map, description) self.camera = None self.none_render_list = [] self.looting = Looting(False)
table.style.align = -1 table.style.valign = -1 app = gui.App() app.init(widget=table, screen=screen, area=rect_pgu) # Загрузка и обработка json-карты f = open(os.path.join('Maps', 'test_map.json')) map = json.loads(f.read()) f2 = open(os.path.join('Descriptions', 'objects.json')) obj_descr = json.loads(f2.read()) objs, back, start_pos = map_loader(map, obj_descr) f.close() f2.close() render_list = objs # Список словарей с объектами и их функциями (если нет функции - None) none_render_list = [] clock = pygame.time.Clock() # camera = Camera(camera_configure, total_level_width, total_level_height) while True: map_address = open_dialog.value for e in pygame.event.get():