Particle system lifecycle
An emitter spawns particles with a lifespan into an array each frame; each particle updates, fades and is removed once its lifespan is exhausted.
What it is
“A particle system is a collection of many, many minute particles that together represent a fuzzy object,” as The Nature of Code puts it — in code, an array of many small independent objects rather than one. Each member of that array is only ever asked one thing: is it “alive or dead”? How particles enter the array in the first place isn’t in what’s quoted here — only how the dead ones are found and removed.
How it works
- Each particle carries its own alive-or-dead test — “is the particle alive or dead?” — rather than the system tracking state externally.
- Whatever moves a particle reuses what came before: the instruction is simply to “keep the same physics model as in previous chapters,” not to invent a particle-specific one.
- A particle that fails the test comes out by removing “one or more elements from an array starting from a given index” — index-based removal, not a filter-and-rebuild of the array.
Parameters & tuning
No numeric knob is evidenced here — no count, spawn rate or decay figure appears in what’s quoted. The one mechanical detail that is evidenced is that removal works by array index, not by particle identity. Motion itself carries whatever forces and tuning your physics model already uses in the rest of the book’s examples; nothing quoted suggests particle-specific behaviour beyond that reuse.
Where it’s been used
The only attested source behind this page is the Nature of Code chapter itself — nothing quoted here ties the pattern to a named artwork. Confetti particle system is the one worked instance of a similar array-of-particles technique in this corpus: it layers launch velocity, decay, gravity, tilt rotation and noise-driven wobble onto each particle for a confetti-burst effect.
Variants & neighbours
L-system replaces this altogether: instead of independent objects each tested and removed on their own, a single string is rewritten wholesale each generation and only turned into drawing afterward — there’s no per-member test, because there’s no population to test.
Cellular automata keep a fixed grid instead of an array whose members are tested and removed: every cell updates in place from its neighbours’ state, and nothing about the population’s size changes the way particles are culled here.
Neuroevolution also works over a population, but its members are whole neural networks scored by fitness and selected against that score, not objects individually tested and removed the way particles are here.
Go deeper
- The Nature of Code — Particle Systems — the chapter this page’s quotes come from.
- The Nature of Code — Daniel Shiffman’s free web book simulating natural systems in p5.js, where this chapter sits.
Connected to
A kind of: Confetti particle system
Further reading: The Nature of Code
Contrast with: Confetti particle system