From e3fd07e606098dd9cdf0b7ed806340d8466b5572 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sun, 11 Feb 2018 22:55:22 +0100 Subject: Reimplement in C++ with SFML (mostly) --- src/main/cpp/Actor.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/cpp/Actor.cpp (limited to 'src/main/cpp/Actor.cpp') diff --git a/src/main/cpp/Actor.cpp b/src/main/cpp/Actor.cpp new file mode 100644 index 0000000..219488d --- /dev/null +++ b/src/main/cpp/Actor.cpp @@ -0,0 +1,27 @@ +#include "Actor.hpp" + +Actor::Actor(std::string _name, unsigned _maxHp, Type _type) : + name(_name), maxHp(_maxHp), type(_type) +{} + +Actor::~Actor() +{} + +void Actor::damage(int amt) +{ + _hp -= amt; + + if (_hp < 0) { + _hp = 0; + _alive = false; + } +} + +void Actor::heal(int amt) +{ + _hp += amt; + + if (_hp > maxHp) { + _hp = maxHp; + } +} -- cgit v1.2.1