Game Development Reference
In-Depth Information
class Firework : public cyclone::Particle
/** Fireworks have an integer type, used for firework rules. */
unsigned type;
* 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.
cyclone::real age;
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.
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.
struct FireworkRule
/** The type of firework that is managed by this rule. */
unsigned type;
/** The minimum length of the fuse. */
cyclone::real minAge;
/** The maximum length of the fuse. */
cyclone::real maxAge;
/** The minimum relative velocity of this firework. */
cyclone::Vector3 minVelocity;
Search Nedrilad ::

Custom Search