class State: def __init__(self): self.player = Player() self.pipes = Pipes() def update(self, dirr): self.player.update(dirr, self.pipes) self.pipes.update() def draw(self, surface): self.pipes.draw(surface) self.player.draw(surface)
if game_state == GameState.CRASH and event.key == pygame.K_r: game_state = GameState.RESET print(event) game_display.fill(config.BLACK) if game_state == GameState.PLAYING: # Add pipes and clean old ones if count == 0: pipes.add_pipe() pipes.clean_pipe() bird.update() pipes.update() if monitor.check_collision(bird, pipes): game_state = GameState.CRASH monitor.check_score(bird, pipes) bird.render(game_display) pipes.render(game_display) monitor.render(game_display) monitor.print_fps(game_display, clock) if game_state == GameState.CRASH: monitor.render_dead(game_display) pygame.display.update() count = (count + 1) % (2 * config.FPS)