def launch_game(gui: GUI, player_info: tuple): gui.quit() pygame.init() main_loop = create_game(player_info[0], 768, 768, True) result = main_loop.run() if result is None: return elif len(result) == 0: string_result = "DRAW" else: winning_players_strings = [ "Player " + str(player.playerNumber) for player in result ] string_result = "WON: " + str(winning_players_strings) end_popup(string_result)
def buildMainFrame(window: Tk, gui: GUI) -> Frame: global main_frame builder = ButtonFrameBuilder("Sokoban", window) builder.setTitleColor("#FF0000") builder.addButton(("Play", lambda: gui.goToFrame(get_selection_frame()))) builder.addButton(("Quit", gui.quit)) main_frame = builder.create() return main_frame
def launch_game(gui: GUI, player_info: tuple): gui.quit() pygame.init() width = 1280 height = 720 speed = int(round((min(width, height) / 1080) * 350)) controllers = [] for player_number, player_class in player_info[0].items(): controllers.append(player_class) boards_folder = os.path.join("res", "boards") parser_result = SokobanBoardParser().parseFile(os.path.join(boards_folder, "test1.txt")) builder = SokobanBoardBuilder(width, height, parser_result, controllers, speed) game = builder.createGame() result = game.run() if result is None: return elif len(result) == 0: string_result = "DRAW" else: winning_players_strings = ["Player " + str(player.playerNumber) for player in result] string_result = "WON: " + str(winning_players_strings) end_popup(string_result)
def launch_gui(): window = Tk() gui = GUI("Sokoban", window) gui.addFrame(buildMainFrame(window, gui)) gui.addFrame(buildSelectionFrame(window, gui)) gui.mainloop()