The Table Engine
health.cpp
Go to the documentation of this file.
1 #include <iostream>
2 
3 #include "health.h"
4 
5 Health::Health() : m_currentHealth(1000) {
6  setName("Health");
7 }
8 
9 Health::Health(int health) : m_currentHealth(health) {
10  setName("Health");
11 }
12 
14  return;
15 }
16 
17 void Health::updateHealth(int amount) {
18  m_currentHealth += amount;
19 }
20 
22  return m_currentHealth;
23 }
void setName(std::string name)
Sets the name of the component.
Definition: component.cpp:19
~Health()
Destructor for the health component.
Definition: health.cpp:13
int m_currentHealth
Current health of the game object.
Definition: health.h:24
Health()
Constructor that initializes the health component.
Definition: health.cpp:5
int getHealth()
Retrieves the current health of the game object.
Definition: health.cpp:21
void updateHealth(int amount)
Updates the health by a specified amount.
Definition: health.cpp:17
Defines the Health class, a component for managing the health of game objects.