Esempio n. 1
0
def wait_for_client(assets_obj: assets.Assets, ui_obj: assets.UserInterface,
                    networking_obj: networking.Networking):
    """waiting screen input handler"""
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                print("end hosting")
                networking_obj.end_hosting(assets_obj, ui_obj)
Esempio n. 2
0
def server_input(assets_obj: assets.Assets, ui_obj: assets.UserInterface,
                 networking_obj: networking.Networking):
    """Singleplayer input handler"""
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_UP:
                assets_obj.player.speed -= assets_obj.player.control_speed
            if event.key == pygame.K_DOWN:
                assets_obj.player.speed += assets_obj.player.control_speed
            if event.key == pygame.K_ESCAPE:
                print("end hosting")
                assets_obj.reset()
                networking_obj.end_hosting(assets_obj, ui_obj)

        if event.type == pygame.KEYUP:
            if event.key == pygame.K_UP:
                assets_obj.player.speed += assets_obj.player.control_speed
            if event.key == pygame.K_DOWN:
                assets_obj.player.speed -= assets_obj.player.control_speed