Game Development Reference
class Firework : public cyclone::Particle
/** Fireworks have an integer type, used for firework rules. */
* The age of a firework determines when it detonates. Age gradually
* decreases; when it passes zero the firework delivers its payload.
* Think of age as fuse-left.
I've used an object-oriented approach here and made the Firework structure a sub-
class of the particle structure. This allows me to add just the new data without chang-
ing the original particle definition.
T HE F IREWORKS R ULES
To define the effect of the whole fireworks display, we need to be able to specify how
one type of particle changes into another. We do this as a set of rules: for each firework
type we store an age and a set of data for additional fireworks that will be spawned
when the age is passed. This is held in a Rules data structure with this form:
Excerpt from src/demos/fireworks/fireworks.cpp
* Firework rules control the length of a firework's fuse and the
* particles it should evolve into.
/** The type of firework that is managed by this rule. */
/** The minimum length of the fuse. */
/** The maximum length of the fuse. */
/** The minimum relative velocity of this firework. */