Workshop › Snake › Step 22 of 28
When the game ends, write "Game Over" in the middle of the board.
```js
if (gameOver) {
ctx.fillStyle = 'white'
ctx.font = '32px sans-serif'
ctx.textAlign = 'center'
ctx.fillText('Game Over', canvas.width / 2, canvas.height / 2)
}
```gameOver is true: pick white, a 32-pixel font, center alignment.fillText(text, x, y) writes the text; half the width and height is the middle of the board.In draw, after the snake's for loop, leave an empty line and write the if (gameOver) block.
Skills: Drawing on a canvas
← Crash into yourself Show the score →