Workshop › Flappy-style Bird › Step 21 of 30
A pipe scores when it has fully passed the bird. But that stays true for every frame until the pipe leaves the
screen. A passed flag on each pipe makes sure it counts only once.
```js
let score = 0
pipes.push({ x: canvas.width, gapY, passed: false })
for (const pipe of pipes) {
pipe.x -= PIPE_SPEED
if (!pipe.passed && pipe.x + PIPE_WIDTH < bird.x - bird.r) {
pipe.passed = true
score += 1
}
}
```passed: false.if scores only a pipe that is not passed yet and is fully behind the bird; then it marks it as passed.!pipe.passed is false, so the same pipe never scores again.let frame = 0, write let score = 0.addPipe, add passed: false to the new pipe.update, inside the pipe loop, under pipe.x -= PIPE_SPEED, write the if block.Skills: Game states
← Through the opening Show the score →