Workshop › Flappy-style Bird › Step 20 of 30
Collision, part two: is the bird fully inside the opening? Its top edge is below gapY and its bottom edge above
gapY + GAP. The bird crashes when it is level with the pipe and not inside the opening.
```js
const overlapsX = bird.x + bird.r > pipe.x && bird.x - bird.r < pipe.x + PIPE_WIDTH
const insideGap = bird.y - bird.r > pipe.gapY && bird.y + bird.r < pipe.gapY + GAP
return overlapsX && !insideGap
```insideGap is true when the bird's box is fully between gapY and gapY + GAP.! means "not": !insideGap is true when the bird is not inside the opening.In hitsPipe, add the insideGap line under overlapsX, and change the return line.
Skills: Collision detection
← Is the bird level with a pipe? Score each pipe once →