Workshop › Breakout › Step 37 of 39
Every frame each particle moves, gravity pulls it down a little, and its life counts down. Dead particles are removed
with filter.
```js
for (const p of particles) {
p.x += p.vx
p.y += p.vy
p.vy += 0.15
p.life -= 1
}
particles = particles.filter((p) => p.life > 0)
```0.15 to vy every frame is gravity: particles curve downward.filter makes a new list with only the particles whose life is above 0.Write the lines at the very top of update, above the arrow-key lines, followed by an empty line.
Skills: Velocity and gravity, Arrays and objects
← Break into sparks Fade out →