g = Game() b = g.load_board('hac-maps/kneighbors.json',1) g.player = Player(model=Sprites.FLYING_SAUCER,name='player') g.change_level(1) key = None while True: if key == 'w': g.move_player(Constants.UP,1) elif key == 's': g.move_player(Constants.DOWN,1) elif key == 'a': g.move_player(Constants.LEFT,1) elif key == 'd': g.move_player(Constants.RIGHT,1) elif key == 'q': break g.clear_screen() g.display_board() for i in g.neighbors(1): print(f'Player: {i.name} ({i.pos[0]},{i.pos[1]})') for i in g.neighbors(1, g.current_board().item(7,7) ): print(f'NPC: {i.name} ({i.pos[0]},{i.pos[1]})') key = Utils.get_key()
current_menu = 'main' elif key == 'B': current_menu = 'main' # Print the screen and interface game.clear_screen() if current_menu == 'main' or current_menu == 'board': print(Utils.white_bright('Current mode: '), end='') if edit_mode: print(Utils.green_bright("EDIT"), end='') else: print(Utils.red_bright('DELETE'), end='') print( f' | Board: {game.current_board().name} - {game.current_board().size} | Cursor @ {game.player.pos}' ) game.display_board() if len(object_history) > 10: del (object_history[0]) if current_menu == 'main': print('Item history:') 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 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:
ui_borders=Utils.RED_SQUARE, ui_board_void_cell=Utils.BLACK_SQUARE, player_starting_position=[4, 4]) mygame.player = Player(name='DaPlay3r', model=Sprites.UNICORN_FACE) mygame.add_board(1, board1) mygame.add_board(2, board2) mygame.change_level(1) key = None # Main game loop while True: mygame.clear_screen() mygame.display_board() # Key handler if key == 'q': print(Utils.yellow_bright("Good bye and thank you for playing!")) break elif key == 'a': # Left mygame.move_player(Constants.LEFT, 1) elif key == 'd': # Right mygame.move_player(Constants.RIGHT, 1) elif key == 'w': # Up mygame.move_player(Constants.UP, 1) elif key == 's':