Workshop › Missile Command-style Defense › Step 12 of 35
Fire an interceptor
What we are doing
You fight back with interceptors. fire(tx, ty) sends one from the base towards a point in the sky, but not towards
the ground.
```js
let shots // your interceptors on their way: { x, y, tx, ty }
shots = []
function fire(tx, ty) {
if (ty > BASE.y - 10) return
shots.push({ x: BASE.x, y: BASE.y, tx, ty })
}
```
What it means
shots holds your interceptors; reset empties it.
Points lower than 10 pixels above the base are ignored: return leaves at once.
An interceptor starts at the base and remembers its target tx, ty, like the enemy missiles.
Your turn
Under let incoming ... write let shots with its comment.
In reset, under incoming = [], write shots = [].
Above the // Move a point ... comment, write fire, followed by an empty line.