Game Development Reference
In-Depth Information
Listing 8-56. Firing the Tank's Weapon
boolean FireWeapon(int WeaponNumber, Vector3 Direction)
{
boolean result = false;
if (WeaponNumber < m_NumberWeapons)
{
result = m_Weapons[WeaponNumber].Fire(Direction,
m_Turret.m_Orientation.GetPosition());
}
return result;
}
The RenderVehicle() function draws the tank's main body, turret, and weapon's projectiles to the
screen and also plays a sound effect if the tank has just hit the ground. (See Listing 8-57.)
Listing 8-57. Rendering the Tank
void RenderVehicle(Camera Cam, PointLight Light, boolean DebugOn)
{
// Render Vehicle
m_MainBody.DrawObject(Cam, Light);
m_Turret.DrawObject(Cam, Light);
// Render Vehicles Weapons and Ammunition if any
for (int i = 0 ; i < m_NumberWeapons; i++)
{
m_Weapons[i].RenderWeapon(Cam, Light, DebugOn);
}
// Shake Camera if Tank hits ground
boolean ShakeCamera = m_MainBody.GetObjectPhysics().GetHitGroundStatus();
if (ShakeCamera)
{
m_MainBody.GetObjectPhysics().ClearHitGroundStatus();
PlayHitGoundSFX();
}
}
The TurnTank() function turns the main body of the tank by TurnDelta degrees. (See Listing 8-58.)
Listing 8-58. Turning the Tank
void TurnTank(float TurnDelta)
{
Vector3 Axis = new Vector3(0,1,0);
m_MainBody.m_Orientation.SetRotationAxis(Axis);
m_MainBody.m_Orientation.AddRotation(TurnDelta);
}
 
Search WWH ::




Custom Search