Workshop › Scorched Earth-style Artillery › Step 21 of 23
Press on the canvas, drag to aim, and let go to fire, like pulling back a slingshot. While the finger is down every movement aims again.
```js
let dragging
dragging = false
dragging = true
canvas.addEventListener('pointermove', (event) => {
if (dragging) pointAt(event)
})
document.addEventListener('pointerup', () => {
if (!dragging) return
dragging = false
fire()
})
```dragging is true between pressing and letting go.thinking, write dragging; at the end of reset, set it to false.pointAt.Skills: Keyboard and mouse input
← Aim with the mouse The atan2 trap →