def update(dt): if not state.started: return if bird.alive: state.t_to_next_pipe -= dt if state.t_to_next_pipe < 0: pipe = Pipe(space=75 * settings.scale, window=window) pipes.append(pipe) state.t_to_next_pipe += 2 for pipe in copy(pipes): if not pipe.visible: pipes.remove(pipe) # Move everything background.update(dt) for pipe in pipes: pipe.update(dt) floor.update(dt) # Check for collisions collision = check_collision(bird, floor) or any([check_collision(bird, pipe) for pipe in pipes]) if collision or bird.y > window.height: bird.die() if not bird.dead: bird.update(dt) if bird.dying and bird.y < -100: bird.stop()
def update(dt): global score if not state.started: return if bird.alive: state.t_to_next_pipe -= dt if state.t_to_next_pipe < 0: pipe = Pipe(space=75 * settings.scale, window=window) pipes.append(pipe) state.t_to_next_pipe += 2 # update score -- problem is for the first one score += 1 # directly setting text on scoreLabel._set_text(str(score)) for pipe in copy(pipes): if not pipe.visible: pipes.remove(pipe) # Move everything background.update(dt) for pipe in pipes: pipe.update(dt) floor.update(dt) # Check for collisions collision = check_collision(bird, floor) or any([check_collision(bird, pipe) for pipe in pipes]) if collision or bird.y > window.height: bird.die() if not bird.dead: bird.update(dt) if bird.dying and bird.y < -100: bird.stop() # reset the score on death score = -1