Game Development Reference
In-Depth Information
The AddArenaObjectsToGravityGrid() function adds all the arena objects in the set that are active to
the gravity grid iGrid that is the input parameter. (See Listing 10-12.)
Listing 10-12. Adding the Arena Objects in the Set to the Gravity Grid
void AddArenaObjectsToGravityGrid(GravityGridEx iGrid)
{
for (int i = 0; i < MAX_ARENA_OBJECTS; i++)
{
if ((m_ArenaObjectSet[i] != null) && (m_Active[i] == true))
{
// Add Mass of AirVehicle to grid
iGrid.AddMass(m_ArenaObjectSet[i]);
}
}
}
The GetArenaObject() function returns the arena object from the set of arena objects in
m_ArenaObjectSet that contains the input ID object id that is currently active. (See Listing 10-13.)
Listing 10-13. Getting an Arena Object Based on Its ID
ArenaObject3d GetArenaObject(String ID)
{
ArenaObject3d temp = null;
for (int i = 0; i < MAX_ARENA_OBJECTS; i++)
{
if (m_ArenaObjectSet[i] != null)
{
if ((m_Active[i]== true) && (m_ArenaObjectSet[i].GetArenaObjectID() == ID))
{
return m_ArenaObjectSet[i];
}
}
}
return temp;
}
The ProcessCollisionWithObject() function (see Listing 10-14) processes the collisions between an
input object Obj and the ArenaObject set by doing the following:
1.
For each arena object in the set that is active, it checks for a collision with the
input Obj object.
2.
If there is a collision, then it processes the collision by calling
ApplyLinearImpulse() to apply the action and reaction forces on both
colliding objects. It starts the explosion graphics and plays the explosion
sound effect for the arena object that is colliding. It plays the explosion
graphic for input object Obj that is involved in the collision. It processes the
damage to the arena object and the object Obj from the collision. If the health
 
Search WWH ::




Custom Search