Workshop › Missile Command-style Defense › Step 14 of 35
Interceptors fly like enemy missiles, only much faster (7 pixels per frame), and are drawn as green lines from the base.
```js
const SHOT_SPEED = 7
for (const s of shots) {
if (stepTowards(s, SHOT_SPEED)) {
s.done = true
}
}
shots = shots.filter((s) => !s.done)
ctx.strokeStyle = '#a3e635'
for (const s of shots) {
ctx.beginPath()
ctx.moveTo(BASE.x, BASE.y)
ctx.lineTo(s.x, s.y)
ctx.stroke()
}
```SHOT_SPEED is the interceptors' speed.update, the same mark-then-filter pattern as the missiles. The { } stay: the next steps add more inside.draw, each interceptor is a green line from the base to where it is.const CITY_XS = ... write const SHOT_SPEED = 7.update, between the countdown block and the missile loop, write the shots loop and its filter (empty line
above).draw, under the missile trail loop, write the green lines.Skills: Velocity and gravity, Drawing on a canvas
← Click the sky An explosion that grows and shrinks →