Workshop › Missile Command-style Defense › Step 19 of 35
A missile is destroyed when it is inside an explosion: its distance to the explosion's center is at most the explosion's radius right now.
```js
if (blasts.some((b) => Math.hypot(m.x - b.x, m.y - b.y) <= radius(b))) {
m.done = true
continue
}
```some is true if at least one blast satisfies the test.Math.hypot(m.x - b.x, m.y - b.y) is the distance from the missile to the blast's center.continue skips the rest of the loop body for it (it does not move on).In update, write the if block at the top of the missile loop, above if (stepTowards(m, m.speed)) {.
Skills: Collision detection
← Impacts explode too Chain reactions →