Workshop › Puzzle Bobble-style Bubble Shooter › Step 27 of 31

The end message

What we are doing

When the game ends, a dark box in the middle says whether you cleared the board or the bubbles reached you.

```js
if (state !== 'playing') {
  ctx.fillStyle = 'rgba(15, 23, 42, 0.85)'
  ctx.fillRect(40, 200, canvas.width - 80, 90)
  ctx.fillStyle = 'white'
  ctx.textAlign = 'center'
  ctx.font = 'bold 24px sans-serif'
  ctx.fillText(state === 'won' ? 'Board cleared!' : 'The bubbles reached you', canvas.width / 2, 238)
  ctx.font = '16px sans-serif'
  ctx.fillText('Space or tap to play again', canvas.width / 2, 268)
}
```

What it means

Your turn

At the end of draw, under the Score line, write the block.

Skills: Drawing on a canvas

All steps

  1. The night sky
  2. One bubble
  3. A grid of cells
  4. Draw the grid
  5. Bubbles that nest
  6. The shooter
  7. Aim upwards
  8. Turn with the arrows
  9. Aim with the pointer
  10. Fire!
  11. Fly
  12. Bounce off the walls
  13. Touching something?
  14. Stick into the grid
  15. Smaller steps
  16. Six neighbours
  17. Flood fill
  18. Three in a row pop
  19. Bubbles that fall
  20. Cut them loose
  21. Show the score
  22. Only useful colors
  23. Count the shots
  24. The ceiling comes down
  25. Win or lose
  26. The danger line
  27. The end message
  28. Play again
  29. Best score
  30. A dotted guide
  31. Build it yourself: swap bubbles