Sunday, December 2, 2012

Damageable Component

My final task for Alpha was to build a component that would keep tabs on the health of the character attached to it. This was vital to the Alpha build because it allowed the player and enemies to be defeated by  depleting their health.

Again, this is going to be a component, so it can be attached to either player or enemy. Overall, this was a  fairly easy class to create. When creating the component, the input will dictate how much health the character  has. As for functions, I made the following methods: one that subtracts from health; one that adds to health;  and one that checks if the character has run out of health. If the character has run out of health, it will delete  that character, and check if it was a player. If it is the player, then it's game over.

A simple, clean class, but necessary for our alpha build. Since I worked on the projectile class, this was  extremely easy to test with enemy projectiles. Fortunately, it works as expected.

No comments:

Post a Comment