Making Damage Possible

Concept summary and lesson

Hit Points

The tanks can only take a certain amount of damage before they're destroyed. We'll represent this as hit points, and they will be another part of the Tank class on the server. The sensor data should also contain the current tank's health, and the health of any enemy tanks that are scanned by the radar.

Tank destruction

When a tank's hit points are zero or less, the tank is destroyed. At that point, it should be removed from the update cycle, but the tank's dead body should stay on the field to be used as cover.

Bullet damage

The bullets already have a damage function, so we just need to call that when a bullet hits a tank, and apply the result to the tank. If we plan ahead for different armor types, we want to know not only the bullet's damage, but also where it came from (in case armor is unequally distributed on the tank). The tank's damage function should take a number and a direction.

Collision damage

When a tank crashes into something, it should take damage. Once again, the damage should depend on not only the absolute amount, but the direction. Most tanks should have tougher armor on the front so that they can ram other tanks and end up winning.

Damage from a collision should depend on the relative velocity at impact. It needs to be a kinetic energy approximation, so that faster hits have damage that grows quadratically.

On collision, the damage is applied to both sides equally, but the tank itself applies its directional armor before deducting hit points.

Examples/demo

Code will go here when we finish the coding session today