Game Development Reference
In-Depth Information
Listing 7-35. Destroying the Particle
void Destroy()
{
GetObjectPhysics().GetVelocity().Clear();
m_Locked = false; // Particle is now free to be used again by the Particle Manager.
m_Active = false; // Do not draw on screen
m_TimeStamp = 0;
// Restore Particle to Original Color
m_Color.x = m_OriginalColor.x;
m_Color.y = m_OriginalColor.y;
m_Color.z = m_OriginalColor.z;
}
The Create() function sets the color of the particle to Color and sets the m_OriginalColor variable to
Color as well. (See Listing 7-36.)
Listing 7-36. Creating a New Particle
void Create(Vector3 Color)
{
m_Color.x = Color.x;
m_Color.y = Color.y;
m_Color.z = Color.z;
m_OriginalColor.x = m_Color.x;
m_OriginalColor.y = m_Color.y;
m_OriginalColor.z = m_Color.z;
}
The LockParticle() function can be used to set up the particle for use. (See Listing 7-37.)
The Lock Particle() function does the following:
Sets up the particle for use by setting m_Active to false and m_Locked to true
1.
Applies a translational force taken from the input parameter Force along the
direction DirectionNormalized
2.
Sets the m_TimeStamp variable to the CurrentTime input parameter
3.
4.
Sets the particle color to the original color for the particle at the time of first
creation
Listing 7-37. Getting a Particle Ready for Use
void LockParticle(float Force, Vector3 DirectionNormalized, long CurrentTime)
{
// 1. Setup particle for use
m_Active = false;
m_Locked = true;
 
Search WWH ::




Custom Search