Game Development Reference
In-Depth Information
Listing 7-50. Modifying the
DrawObject()
Function to Render Explosions
void DrawObject(Camera Cam, PointLight light)
{
RenderExplosions(Cam,light);
// Rest of Code
}
The
UpdateObject3d()
function has to be modified to update the explosions, by calling
UpdateExplosions()
. (See Listing 7-51.)
Listing 7-51. Modifying the
UpdateObject3d()
Function
void UpdateObject3d()
{
if (m_Visible)
{
// Update Object3d Physics
UpdateObjectPhysics();
}
// Update Explosions associated with this object
UpdateExplosions();
}
Creating Game Object Statistics
In order to track the game-related properties, such as health, we have to create a new class that
holds these statistics.
Creating the Stats Class
The Stats class holds the game-related statistics for our game objects. The game-related properties
we will use for our Drone Grid example are health, kill value, and damage value.
The
m_Health
variable holds a game object's health and is defaulted to 100 to indicate full health.
private int m_Health = 100;
The
m_KillValue
variable indicates the point value of this object when it is destroyed.
private int m_KillValue = 50;
The
m_DamageValue
variable is the amount that is subtracted from the health of the player when this
object collides with the player's power pyramid.
private int m_DamageValue = 25;