mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-01 17:55:48 +00:00
Merging game
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// Created by Tom Augier on 2021-05-20.
|
||||
// Edited by Benjamin Henry on 2021-05-20.
|
||||
// Edited by Louis Auzuret on 2021-05-20.
|
||||
//
|
||||
|
||||
#include "HealthComponent.hpp"
|
||||
|
||||
namespace Bomberman
|
||||
{
|
||||
HealthComponent::HealthComponent(WAL::Entity &entity)
|
||||
: WAL::Component(entity),
|
||||
_healthPoint()
|
||||
{}
|
||||
|
||||
HealthComponent::HealthComponent(WAL::Entity &entity, unsigned int healthPoint)
|
||||
: WAL::Component(entity),
|
||||
_healthPoint(healthPoint)
|
||||
{}
|
||||
|
||||
WAL::Component *HealthComponent::clone(WAL::Entity &entity) const
|
||||
{
|
||||
return new HealthComponent(entity);
|
||||
}
|
||||
|
||||
void HealthComponent::addHealthPoint(unsigned int healthPoint)
|
||||
{
|
||||
this->_healthPoint += healthPoint;
|
||||
}
|
||||
|
||||
void HealthComponent::takeDmg(unsigned int damage)
|
||||
{
|
||||
if (damage >= this->_healthPoint) {
|
||||
this->_healthPoint = 0;
|
||||
} else
|
||||
this->_healthPoint -= damage;
|
||||
}
|
||||
|
||||
unsigned int HealthComponent::getHealthPoint(void) const
|
||||
{
|
||||
return (this->_healthPoint);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user