Game Development Reference
In-Depth Information
The AddNewArenaObject() function (see Listing 10-9) adds a new arena object into the set of arena
objects by:
Finding an empty slot in the m_ArenaObjectSet array
1.
2.
If an empty slot is found, setting the new input arena object to invisible;
setting the empty slot to point to the new arena object; increasing
the number of arena objects in the set by incrementing the
m_NumberArenaObjects variable; and returning true
3.
Returning false if an empty slot is not found
Listing 10-9. Adding a New Arena Object to the Set
boolean AddNewArenaObject(ArenaObject3d ArenaObj)
{
boolean result = false;
for (int i = 0; i < MAX_ARENA_OBJECTS; i++)
{
if (m_ArenaObjectSet[i] == null)
{
ArenaObj.SetVisibility(false);
m_ArenaObjectSet[i] = ArenaObj;
m_NumberArenaObjects++;
return true;
}
}
return result;
}
The SetSoundOnOff() function sets the sound effects for the set of arena objects to on or off, based
on the input parameter Value . For each valid arena object, the SetSFXOnOff() function is called.
(See Listing 10-10.)
Listing 10-10. Setting the Sound Effects for the ArenaObject Set
void SetSoundOnOff(boolean Value)
{
for (int i = 0; i < MAX_ARENA_OBJECTS; i++)
{
if (m_ArenaObjectSet[i] != null)
{
m_ArenaObjectSet[i].SetSFXOnOff(Value);
}
}
}
The ProcessCollisionsWeapon() function (see Listing 10-11) processes the collision between a
weapon's ammunition and arena objects in the set by
1.
Determining the active status for each element in the ArenaObject set
2.
If the element is active, checking for collisions between that arena object and
the ammunition from the input iWeapon weapon
 
Search WWH ::




Custom Search