hit_model=bg_color + Graphics.Sprites.DECIDUOUS_TREE + Utils.Style.RESET_ALL, hit_callback=sprout, ) row = g.player.pos[0] column = g.player.pos[1] + 1 if key == "w" or key == "z": projectile.set_direction(Constants.UP) row = g.player.pos[0] - 1 column = g.player.pos[1] elif key == "s": projectile.set_direction(Constants.DOWN) row = g.player.pos[0] + 1 column = g.player.pos[1] elif key == "a" or key == "q": projectile.set_direction(Constants.LEFT) row = g.player.pos[0] column = g.player.pos[1] - 1 hit_wave_obj.play() g.add_projectile(g.current_level, projectile, row, column) g.timer -= projectile.range elif key == "p": if g.state == Constants.RUNNING: g.pause() else: g.start() key = Utils.get_key() current_state = "title" g.save_config("settings", "settings-suparex.json")
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"))
cnt = 0 for o in object_history: print(f"{cnt}: {o.model}", end=" ") cnt += 1 print("") print(f"Current item: {current_object.model}") if not (current_menu == "main" and game.config("settings")["menu_mode"] == "hidden"): game.display_menu(current_menu, Constants.ORIENTATION_VERTICAL, 15) for m in dbg_messages: Utils.debug(m) for m in info_messages: Utils.info(m) for m in warn_messages: Utils.warn(m) if current_menu == "boards_list": key = input("Enter your choice (and hit ENTER): ") else: key = Utils.get_key() # Before saving we need to transform the object library into reference that json can # understand reflib = [] for o in game.config("settings")["object_library"]: reflib.append(Game._obj2ref(o)) game.config("settings")["object_library"] = reflib # Let's also save the partial display viewport game.config("settings")["partial_display_viewport"][0] = viewport_height game.config("settings")["partial_display_viewport"][1] = viewport_width game.save_config("settings", os.path.join(editor_config_dir, "settings.json"))