Game Development Reference
In-Depth Information
Next, we must make modifications to the
UpdateGravityGrid()
function. If the tank's main body is
visible, we have to add the tank's main body and the tank's active ammunition to the gravity grid.
(See Listing 8-68.)
Listing 8-68. Modifying the
UpdateGravityGrid()
Function
if (m_Tank.GetMainBody().IsVisible())
{
m_Grid.AddMass(m_Tank.GetMainBody());
NumberMasses = m_Tank.GetWeapon(0).GetActiveAmmo(0, Masses);
m_Grid.AddMasses(NumberMasses, Masses);
}
The
onDrawFrame()
function must also be modified with additional code.
The tank has to be updated by calling the
UpdateVehicle()
function.
m_Tank.UpdateVehicle();
The tank is rendered using the
RenderVehicle()
function.
m_Tank.RenderVehicle(m_Camera, m_PointLight, false);
Next, run the project, and you should see something similar to Figure
8-7
and Figure
8-8
.
Figure 8-7.
The arena object