Workshop › Puzzle Bobble-style Bubble Shooter › Step 26 of 31
The danger line
What we are doing
The player should see the line bubbles must not cross, and after the game no more shots can be fired.
```js
if (state !== 'playing' || shot) return
ctx.fillStyle = 'rgba(239, 68, 68, 0.5)'
ctx.fillRect(0, DANGER, canvas.width, 2)
```
What it means
shoot does nothing unless the game is being played (or while a bubble is still flying).
- The danger line is a 2-pixel red rectangle across the board.
Your turn
- In
shoot, change the first line to if (state !== 'playing' || shot) return.
- In
draw, under the ceiling, draw the danger line.
Skills: Game states, Drawing on a canvas
← Win or lose The end message →
All steps
- The night sky
- One bubble
- A grid of cells
- Draw the grid
- Bubbles that nest
- The shooter
- Aim upwards
- Turn with the arrows
- Aim with the pointer
- Fire!
- Fly
- Bounce off the walls
- Touching something?
- Stick into the grid
- Smaller steps
- Six neighbours
- Flood fill
- Three in a row pop
- Bubbles that fall
- Cut them loose
- Show the score
- Only useful colors
- Count the shots
- The ceiling comes down
- Win or lose
- The danger line
- The end message
- Play again
- Best score
- A dotted guide
- Build it yourself: swap bubbles