Workshop › Lunar Lander › Step 29 of 31
Every frame each piece falls with the same gravity as the lander and loses one frame of life. Pieces with no life left are removed. This runs even after the crash, so it goes before the "not flying" check.
```js
for (const d of debris) {
d.vy += gravity
d.x += d.vx
d.y += d.vy
d.life -= 1
}
debris = debris.filter((d) => d.life > 0)
```filter keeps only the pieces with life left.if (state !== 'flying') return, so it keeps running after the crash.In update, write the lines at the very top, above if (state !== 'flying') return.
Skills: Velocity and gravity
← Burst into pieces Draw the wreck →