Game Development Reference
In-Depth Information
m_Particles[i].GetObjectPhysics().SetVelocity(GetRandomParticleVelocity(i,MaxVeloci
ty,MinVelocity));
m_Particles[i].m_Orientation.SetScale(m_ParticleSize);
if (m_RandomColors)
{
m_Particles[i].SetColor(GenerateRandomColor());
}
else
{
m_Particles[i].SetColor(m_ParticleColor);
}
m_Particles[i].SetTimeDelay(m_ParticleLifeSpan);
}
}
The RenderExplosion() function draws all the particles that make up the explosion and are active to
the screen. (See Listing 7-48.)
Listing 7-48. Rendering the Explosion
void RenderExplosion(Camera Cam, PointLight light)
{
// Render Explosion
for (int i = 0; i < m_NumberParticles; i++)
{
if (m_Particles[i].GetActiveStatus() == true)
{
m_Particles[i].Render(Cam, light);
}
}
}
The UpdateExplosion() function updates the explosion. (See Listing 7-49.)
The function does the following:
1.
If the explosion is not active, then it returns.
2.
For the active particles, it sets the color randomly, if particle color animation
is turned on.
For the active particles, it updates the particle by calling UpdateParticle() .
3.
4.
If any particle is active, then the entire explosion is set to active.
Listing 7-49. Updating the Explosion
void UpdateExplosion()
{
if (!m_ExplosionActive)
{
return;
}
 
Search WWH ::




Custom Search