The Table Engine
Health Class Reference

A component for managing health of game objects. More...

#include <health.h>

+ Inheritance diagram for Health:
+ Collaboration diagram for Health:

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...
 
- Public Member Functions inherited from Component
 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...
 
GameObjectgetOwner ()
 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

- Protected Attributes inherited from Component
std::string m_name
 Name of the component, useful for identification or debugging. More...
 
GameObjectm_owner
 Pointer to the GameObject that owns this component. More...
 

Detailed Description

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.

Definition at line 22 of file health.h.

Constructor & Destructor Documentation

◆ Health() [1/2]

Health::Health ( )

Constructor that initializes the health component.

Definition at line 5 of file health.cpp.

◆ Health() [2/2]

Health::Health ( int  health)

Definition at line 9 of file health.cpp.

◆ ~Health()

Health::~Health ( )

Destructor for the health component.

Definition at line 13 of file health.cpp.

Member Function Documentation

◆ getHealth()

int Health::getHealth ( )

Retrieves the current health of the game object.

Returns
Integer representing the current health.

Definition at line 21 of file health.cpp.

◆ updateHealth()

void Health::updateHealth ( int  amount)

Updates the health by a specified amount.

Parameters
amountThe amount to add to the current hepalth (can be negative for damage).

Definition at line 17 of file health.cpp.

Member Data Documentation

◆ m_currentHealth

int Health::m_currentHealth
private

Current health of the game object.

Definition at line 24 of file health.h.


The documentation for this class was generated from the following files: