Workshop › Flappy-style Bird › Step 19 of 30
Collision, part one. We treat the bird as the square box around its circle and ask: does it overlap the pipe horizontally? For now, being level with a pipe ends the game, even in the opening.
```js
function hitsPipe(pipe) {
const overlapsX = bird.x + bird.r > pipe.x && bird.x - bird.r < pipe.x + PIPE_WIDTH
return overlapsX
}
if (hitGround || hitSky || pipes.some(hitsPipe)) state = 'over'
```&& means "and".return overlapsX gives the answer back to the caller.pipes.some(hitsPipe) is true if any pipe is hit.addPipe, leave an empty line and write hitsPipe.update, add || pipes.some(hitsPipe) to the game-over condition.Skills: Collision detection
← Remove the pipes you passed Through the opening →