Workshop › Flappy-style Bird › Step 11 of 30
When the bird's bottom edge reaches the ground, or its top edge the top of the screen, the game is over: the state
becomes 'over', everything freezes, and flapping does nothing.
```js
function flap() {
if (state === 'over') return
state = 'playing'
bird.vy = FLAP
}
bird.y += bird.vy
const hitGround = bird.y + bird.r >= canvas.height
const hitSky = bird.y - bird.r <= 0
if (hitGround || hitSky) state = 'over'
```>= means "greater than or equal", <= "less than or equal". Each comparison is true or false, and we give
the answers names.hitGround || hitSky: either one ends the game.'over', update returns at once (frozen), and flap returns too.flap, add if (state === 'over') return as the first line.update, under bird.y += bird.vy, leave an empty line and write the three new lines.Skills: Collision detection, Game states
← Wait for the first flap Tell the player →