Game Development Reference
In-Depth Information
The UpdateArenaObject() function updates the arena object enemy. (See Listing 8-7.)
Listing 8-7. Updating the Arena Object
void UpdateArenaObject()
{
if (IsVisible() == true)
{
// Check Bounds for Z
if (m_Orientation.GetPosition().z >= m_ZMaxBoundary)
{
Vector3 v = GetObjectPhysics().GetVelocity();
if (v.z > 0)
{
v.z = -v.z;
}
}
else
if (m_Orientation.GetPosition().z <= m_ZMinBoundary)
{
Vector3 v = GetObjectPhysics().GetVelocity();
if (v.z < 0)
{
v.z = -v.z;
}
}
// Check bounds for X
if (m_Orientation.GetPosition().x >= m_XMaxBoundary)
{
Vector3 v = GetObjectPhysics().GetVelocity();
if (v.x > 0)
{
v.x = -v.x;
}
}
if (m_Orientation.GetPosition().x <= m_XMinBoundary)
{
Vector3 v = GetObjectPhysics().GetVelocity();
if (v.x < 0)
{
v.x = -v.x;
}
}
}
// Update Physics for this object
UpdateObject3d();
}
 
Search WWH ::




Custom Search