Description: Life entity (base class). Written for OOP Review.
life_entity Class Reference
Base life entity class. More...
#include <life_entity.h>
Public Member Functions | |
| life_entity () | |
| Base life entity class constructor. | |
| virtual | ~life_entity () |
| Base life entity class destructor. | |
| char | getLifeEntityCount () |
| Get number of life entities currently spawned. | |
| int | getHealth () |
| Returns the current status of the entity's life points. | |
| char | getLevel () |
| Get the current level of the entity. | |
| int | rollDamage () |
| Entity rolls for damage. | |
| virtual void | takeDamage (int) |
| Take damage from apponent. | |
Protected Attributes | |
| int | _health |
| Entity health variable (int). | |
| char | _level |
| Entity level variable (char). | |
Static Protected Attributes | |
| static int | lifeEntityCount = 0 |
| Static entity count variable (int). | |
Detailed Description
Base life entity class.
This class is inherited by all life entities (user, enemies, anything you can think of that is supposed to live).
Example:
// Create a pointer to a life_entity object. life_entity *currentEnemy; int main() { // Use the pointer to create a new armoured_vehicle (derived class) currentEnemy = new armoured_vehicle(user); }
Definition at line 23 of file life_entity.h.
Constructor & Destructor Documentation
| life_entity | ( | ) |
Base life entity class constructor.
This class is inherited by all life entities (user, enemies, anything you can think of that is supposed to live).
Example:
// Create a pointer to a life_entity object. life_entity *currentEnemy; // Life entity object int main() { // Use the pointer to create a new armoured_vehicle (derived class) currentEnemy = new armoured_vehicle(user); }
Definition at line 7 of file life_entity.cpp.
| ~life_entity | ( | ) | [virtual] |
Base life entity class destructor.
This class is inherited by all life entities (user, enemies, anything you can think of that is supposed to live).
Example:
// Create a pointer to a life_entity object. life_entity *currentEnemy; int main() { // Use the pointer to create a new armoured_vehicle (derived class) currentEnemy = new armoured_vehicle(user); delete currentEnemy; }
Definition at line 18 of file life_entity.cpp.
Member Function Documentation
| int getHealth | ( | ) |
Returns the current status of the entity's life points.
Example:
int lifePoints = getHealth();
Definition at line 31 of file life_entity.cpp.
| char getLevel | ( | ) |
Get the current level of the entity.
No error checking is performed. If you wish to use this you should consider adding a check or two. The level is currently stored in a char, and therefore maxes out at 255 (0xFF).
Example:
char currentLevel = getLevel();
Definition at line 37 of file life_entity.cpp.
| char getLifeEntityCount | ( | ) |
Get number of life entities currently spawned.
Example:
char count = getLifeEntityCount();
Definition at line 25 of file life_entity.cpp.
| int rollDamage | ( | ) |
Entity rolls for damage.
All entities use this to roll for damage (against thier opponent).
Example:
int roll = rollDamage();
Definition at line 45 of file life_entity.cpp.
| virtual void takeDamage | ( | int | ) | [virtual] |
Take damage from apponent.
Derived classes set this up on specific to thier needs.
- Parameters:
-
roll The damage roll to be passed in (most likely from rollDamage()).
Definition at line 119 of file life_entity.h.
Field Documentation
int _health [protected] |
Entity health variable (int).
Definition at line 119 of file life_entity.h.
char _level [protected] |
Entity level variable (char).
Definition at line 131 of file life_entity.h.
int lifeEntityCount = 0 [static, protected] |
Static entity count variable (int).
Definition at line 136 of file life_entity.h.
