g.current_level = 0 g.player = Player(model=bg_color + Graphics.Sprites.PANDA + Graphics.Style.RESET_ALL) g.player.name = "Zigomar" g.player.max_y = g.player.pos[0] g.player.dy = gravity_speed g.player.last_y = g.player.pos[0] g.player.last_x = g.player.pos[1] g.timer = 60 g.score = 0 g.obj_stack = [] g.pause() if os.path.exists("settings-suparex.json"): g.load_config("settings-suparex.json", "settings") if g.config("settings")["player_name"] is not None: g.player.name = g.config("settings")["player_name"] else: g.create_config("settings") g.config("settings")["player_name"] = g.player.name g.config("settings")["hiscores"] = [] names = [ "Marie Curie", "Jane Goodall", "Ada Lovelace", "Rosalind Franklin", "Dorothy Hodgkin", "Jocelyn Bell Burnell", "Chien-Shiung Wu", "Irène Joliot-Curie", "Vera Rubin",
from gamelib.Game import Game g = Game() c = g.load_config("test-config.json", "test") print(f"Version: {g.config('test')['config_file_version']}") g.config("test")["directories"].append("test_boards") g.save_config("test", "config-test.json") print(g.config("blorp"))
while True: game.clear_screen() print( Utils.cyan_bright("HAC-GAME-LIB - EDITOR v" + Constants.HAC_GAME_LIB_VERSION)) # Create config_dir if not exist and populate it with a directories.json file. if (not os.path.exists(config_dir) or not os.path.isdir(config_dir) or not os.path.exists(base_config_dir) or not os.path.isdir(base_config_dir) or not os.path.isdir(editor_config_dir) or not os.path.exists( os.path.join(editor_config_dir, "settings.json"))): first_use() else: game.load_config(os.path.join(editor_config_dir, "settings.json"), "settings") viewport_height = game.config( "settings")["partial_display_viewport"][0] viewport_width = game.config("settings")["partial_display_viewport"][1] viewport_board.size = [viewport_width * 2, viewport_height * 2] viewport_board.init_board() # The objects library is stored as a list of references. We need to convert that # before using the objects. objlib = [] for ref in game.config("settings")["object_library"]: objlib.append(Game._ref2obj(ref)) game.config("settings")["object_library"] = objlib print("Looking for existing maps in selected directories...", end="") default_map_dir = None hmaps = [] for directory in game.config("settings")["directories"]: # files = [f'{directory}/{f}' for f in os.listdir(directory)] # hmaps += files