Пример #1
0
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)
Пример #2
0
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)