Workshop › Pool › Step 14 of 33
The aim line only makes sense while aiming; while the balls roll it just follows the cue ball around. We draw it only in
'aiming'.
```js
if (state === 'aiming') {
ctx.strokeStyle = 'rgba(255, 255, 255, 0.6)'
ctx.lineWidth = 1
ctx.beginPath()
ctx.moveTo(cue.x, cue.y)
ctx.lineTo(cue.x + Math.cos(aim) * 400, cue.y + Math.sin(aim) * 400)
ctx.stroke()
}
```if (state === 'aiming') { ... }, two more spaces in.Put if (state === 'aiming') { above the six aim-line lines in draw, indent them, and close with }.
Skills: Game states, Drawing on a canvas
← Aiming and rolling Count the shots →