Game Development Reference
In-Depth Information
// Tank Weapons and Pyramid
int NumberWeapons = m_Tank.GetNumberWeapons();
for (int j=0; j < NumberWeapons; j++)
{
CollisionObj = m_Tank.GetWeapon(j).CheckAmmoCollision(m_Pyramid);
if (CollisionObj != null)
{
CollisionObj.ApplyLinearImpulse(m_Pyramid);
//Process Damage
m_Pyramid.TakeDamage(CollisionObj);
// Obj Explosion
m_Pyramid.ExplodeObject(ExplosionMaxVelocity, ExplosionMinVelocity);
m_Pyramid.PlayExplosionSFX();
// Set Pyramid Velocity and Acceleration to 0
m_Pyramid.GetObjectPhysics().ResetState();
}
}
}
The ProcessTankCollisions() function does the following:
1.
Returns, if the tank's main body is not visible.
2.
Checks for a collision with the player's ammunition and the enemy tank's
main body.
3.
If there is a collision, it
a.
Applies forces to the player's ammunition and the tank
b. Starts an explosion sequence for the tank
c.
Plays an explosion sound effect
d. Processes the damage caused by the player's ammunition on the tank's main body
e.
Adds the kill value of the tank to the player's score, if the health of the tank's main
body is less than or equal to 0. It also sets the visibility of the tank's main body and
the tank's turret to false.
4.
Checks for a collision between the weapon's ammunition and the player's
power pyramid for each of the tank's weapons.
5.
If there is a collision, it
a.
Applies forces to the ammunition and the pyramid
b. Processes the damage to the pyramid
c.
Starts the pyramid's explosion effect
d. Plays the pyramid's explosion sound effect
e.
Resest the pyramid's physics so that it does not move from the collision
with the tank's ammunition.
Search WWH ::




Custom Search