Game Development Reference
In-Depth Information
For each tank in the tank fleet that is active
1.
Check for a collision between the ammunition from the tank's weapons and
the object Obj.
2.
If there is a collision, apply a linear force to the ammunition and the object by
calling the ApplyLinearImpulse() function
Process the damage to the object by calling TakeDamage()
3.
Start the explosion graphic for the object by calling StartExplosion()
4.
Listing 10-21. Collision Processing Between an Object and a Tank's Live Ammunition
boolean ProcessWeaponAmmoCollisionObject(Object3d Obj)
{
Object3d CollisionObj = null;
boolean hitresult = false;
for (int i = 0; i < MAX_TANKS; i++)
{
if ((m_TankFleet[i] != null) && (m_InService[i] == true))
{
int NumberWeapons = m_TankFleet[i].GetNumberWeapons();
for (int j=0; j < NumberWeapons; j++)
{
CollisionObj = m_TankFleet[i].GetWeapon(j).CheckAmmoCollision(Obj);
if (CollisionObj != null)
{
hitresult = true;
CollisionObj.ApplyLinearImpulse(Obj);
//Process Damage
Obj.TakeDamage(CollisionObj);
// Obj Explosion
SphericalPolygonExplosion Exp = Obj.GetExplosion(0);
if (Exp != null)
{
Exp.StartExplosion(Obj.m_Orientation.GetPosition(),
m_VehicleExplosionMaxVelocity, m_VehicleExplosionMinVelocity);
}
}
}
}
}
return hitresult;
}
 
Search WWH ::




Custom Search