Game Development Reference
In a game development studio it is often the art staff who need to decide how the
particles in a game will behave. In this case it is inconvenient to have the rules defined
in code. Many developers incorporate some kind of text file format into their engine,
which can read in easy-to-edit particle rules created by level designers or artists. Some
developers have gone further to create specific tools where an artist can interactively
tweak the behavior of particles in a WYSIWYG environment. This tool then saves out
some file format that defines the rules, to be later read in by the engine.
T HE I MPLEMENTATION
At each frame, each firework has its age updated and is checked against the rules. If its
age is past the threshold, then it will be removed and more fireworks will be created
in its place (the last stage of the chain reaction spawns no further fireworks).
Using the particle update function to perform the physics, the firework update
function now looks like this:
Excerpt from src/demos/fireworks/fireworks.cpp
* Fireworks are particles, with additional data for rendering and
class Firework : public cyclone::Particle
* Updates the firework by the given duration of time. Returns true
* if the firework has reached the end of its life and needs to be
bool update(cyclone::real duration)
// Update our physical state
// We work backward from our age to zero.
age -= duration;
return (age < 0);
Notice that if we don't have any spare firework slots when a firework explodes
into its components, then not all the new fireworks will be calculated. In other words,
when resources are tight, older fireworks get priority.