Game Development Reference
In-Depth Information
The CreateFiringSFX() function creates a new sound effect associated with an Ammunition object.
(See Listing 7-15.)
Listing 7-15. Creating Sound Effects
void CreateFiringSFX(SoundPool Pool, int ResourceID)
{
m_FireSFXIndex = AddSound(Pool, ResourceID);
}
The PlayFiringSFX() function plays the sound effect created by the CreateFiringSFX() function.
(See Listing 7-16.)
Listing 7-16. Playing Back the Ammunition Sound Effect
void PlayFiringSFX()
{
if (m_FireSFXIndex >= 0)
{
PlaySound(m_FireSFXIndex);
}
}
The Reset() function sets the firing status of the ammunition and ammunition spent status to false,
to indicate that the ammunition has not been fired and is ready for use. It also sets the velocity to 0.
(See Listing 7-17.)
Listing 7-17. Resetting the Ammunition
void Reset()
{
m_FireStatus = false;
m_AmmunitionSpent = false;
GetObjectPhysics().GetVelocity().Set(0, 0, 0);
}
The RenderAmmunition() function draws the ammunition to the screen by calling the DrawObject()
function in the parent Object3d class. (See Listing 7-18.)
Listing 7-18. Rendering the Ammunition
void RenderAmmunition(Camera Cam, PointLight light, boolean DebugOn)
{
DrawObject(Cam, light);
}
The UpdateAmmunition() function updates the ammunition object by calling the UpdateObject3d()
function in the superclass. (See Listing 7-19.)
 
Search WWH ::




Custom Search