def handle_input(log, END_GAME = False): """ Handles all external input,such as those keyboard and mouse. """ for event in pygame.event.get(): keys = pygame.key.get_pressed() # Closing handle_quit(event) if keyboard.queue_prompt(event): game_state.next_wave() # Pausing game if keyboard.pause_prompt(keys): game_state.toggle_paused() # Hero's movement hero_dir = keyboard.movement(keys) game_state.hero.change_direction(hero_dir) #END_GAME global game_state handle_quit(event, END_GAME) if keyboard.restart(event, END_GAME): if game_state.mode == "FIXED": new_choice = "DYNAMIC" else: new_choice = "FIXED" game_state = GameState(new_choice) log.refresh(new_choice) log.first_row() # Sound Adjustment if keyboard.music_prompt(keys): dj.switch_background_music() if keyboard.increase_prompt(keys): dj.increase_volume() if keyboard.decrease_prompt(keys): dj.decrease_volume() # Shoot Laser if keyboard.laser_prompt(keys): if game_state.hero.laser_equipped: game_state.hero.is_firing_laser = True game_state.hero.fire_time = time.clock() # Shoot Pew if keyboard.pew_prompt(keys): if game_state.hero.ok_to_shoot(): game_state.hero_fire() dj.play_pew()