The Table Engine
|
A component for managing health of game objects. More...
#include <health.h>
Public Member Functions | |
Health () | |
Constructor that initializes the health component. More... | |
Health (int health) | |
~Health () | |
Destructor for the health component. More... | |
int | getHealth () |
Retrieves the current health of the game object. More... | |
void | updateHealth (int amount) |
Updates the health by a specified amount. More... | |
![]() | |
Component () | |
Default constructor for the Component. More... | |
Component (std::string name) | |
Constructs a Component with a specified name. More... | |
virtual | ~Component () |
Virtual destructor for safe polymorphic use. More... | |
std::string | getName () |
Retrieves the name of the component. More... | |
GameObject * | getOwner () |
Retrieves the GameObject that owns this component. More... | |
void | setName (std::string name) |
Sets the name of the component. More... | |
void | setOwner (GameObject *owner) |
Sets the GameObject owner of this component. More... | |
virtual void | input () |
Virtual method for handling input, intended to be overridden by derived components. More... | |
virtual void | update () |
Virtual method for updating the component's state, intended to be overridden by derived components. More... | |
virtual void | render () |
Virtual method for rendering, intended to be overridden by derived components. More... | |
Private Attributes | |
int | m_currentHealth |
Current health of the game object. More... | |
Additional Inherited Members | |
![]() | |
std::string | m_name |
Name of the component, useful for identification or debugging. More... | |
GameObject * | m_owner |
Pointer to the GameObject that owns this component. More... | |
A component for managing health of game objects.
The Health class extends the Component class and provides mechanisms to manage the health of game objects. It allows setting, adjusting, and querying the health status, facilitating the implementation of game rules related to life or vitality of characters and other entities within the game.
Health::Health | ( | ) |
Constructor that initializes the health component.
Definition at line 5 of file health.cpp.
Health::Health | ( | int | health | ) |
Definition at line 9 of file health.cpp.
Health::~Health | ( | ) |
Destructor for the health component.
Definition at line 13 of file health.cpp.
int Health::getHealth | ( | ) |
Retrieves the current health of the game object.
Definition at line 21 of file health.cpp.
void Health::updateHealth | ( | int | amount | ) |
Updates the health by a specified amount.
amount | The amount to add to the current hepalth (can be negative for damage). |
Definition at line 17 of file health.cpp.
|
private |