Workshop › Missile Command-style Defense › Step 16 of 35
An interceptor that arrives becomes an explosion. Every frame each explosion gets one frame older, and old ones are removed.
```js
let blasts // explosions: { x, y, age }
blasts = []
blasts.push({ x: s.x, y: s.y, age: 0 })
for (const b of blasts) b.age += 1
blasts = blasts.filter((b) => b.age < BLAST_FRAMES)
```for (const b of blasts) b.age += 1: a loop with a single command can be written on one line.filter keeps only the blasts younger than BLAST_FRAMES.let shots ... write let blasts with its comment; in reset, under shots = [], write blasts = [].update, under s.done = true, write the blasts.push line.shots = shots.filter(...) line, leave an empty line and write the two blast lines.Skills: Game states
← An explosion that grows and shrinks Draw the explosions →