Exemple #1
0
def main():
    # Initialize PyGame
    pygame.init()
    # Instantiate game
    game = Game("Snake")
    # Load game
    game.load()

    # ------ Main Program Loop ------
    while game.is_running():
        # Process events (e.g. keystrokes, mouseclicks)
        game.process_events()
        # Run game logic (e.g. object positions, player attributes)
        game.run_logic()
        # Draw the current frame (e.g. the graphics)
        game.display_frame()
        # Pause until next frame
        game.update_clock()

    # Once the main program loop has stopped (program finished running),
    # Close all open windows
    pygame.quit()
Exemple #2
0
def main ():
    # Initialize PyGame
    pygame.init()
    # Instantiate game
    game = Game ("Snake")
    # Load game
    game.load()
    
    # ------ Main Program Loop ------
    while game.is_running():
        # Process events (e.g. keystrokes, mouseclicks)
        game.process_events()
        # Run game logic (e.g. object positions, player attributes)
        game.run_logic()
        # Draw the current frame (e.g. the graphics)
        game.display_frame()
        # Pause until next frame
        game.update_clock()

    # Once the main program loop has stopped (program finished running),
    # Close all open windows
    pygame.quit()
Exemple #3
0
        answer = input(
            f'Введите имя нового игрока (по умолчанию Неизвестный #{i}) :')
        name_player = (answer if answer else 'Неизвестный ' + '#' + str(i))
        # TODO: проверить имя на уникальность
        # присваиваем тип игрока
        loto.players.append(
            Human(name_player, i) if choose_who(
            ) else Computer(name_player, i))
        # TODO: проверка типов

    print('\nПоехали!\n')
    while loto.is_running:
        # вытаскиваем очередной бочонок
        barrel = loto.pull_out_barrel()
        # что у игроков ?
        for player in loto.players:
            result = player.move_on(barrel)  # 0- продолжаем
            if result == 1:
                print('\nПобеда !!! Карточка заполнена. Игра закончена')
                loto.is_running = False
                break
            elif result < 0:
                print(f'Игрок {player.name} выбыл из игры')
                loto.running_players -= 1
                if loto.running_players == 0:  # остались ли игроки?
                    result = -100  # никого не осталось
                    loto.is_running = False
                    break
    winner = (player.name if result != -100 else 'не определён')
    print(f'\nПобедитель {winner}  ({loto.lap - 1} раунд)')