-
Notifications
You must be signed in to change notification settings - Fork 0
/
Damagable.hpp
53 lines (42 loc) · 1.02 KB
/
Damagable.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef LD32_ENEMY_HPP
#define LD32_ENEMY_HPP
#include <Engine/SpriteNode.hpp>
#include <SFML/Audio.hpp>
#include "misc.hpp"
class Damagable: public engine::SpriteNode {
class ContactHandler: public engine::util::EventHandler<b2Contact*, const b2Manifold*> {
Damagable* m_enemy;
public:
ContactHandler(Damagable* p) : m_enemy(p) {
}
virtual void handle(b2Contact*, const b2Manifold* manifold);
};
protected:
float m_health;
float m_maxHealth;
float m_damage;
bool m_dead;
bool m_hit;
ContactHandler m_preCH;
float m_invulnTime;
sf::Sound* m_deathSound;
sf::Sound* m_hurtSound;
public:
Damagable(engine::Scene* scene);
virtual ~Damagable();
virtual uint8_t GetType() const {
return NT_ENEMY;
}
virtual void Damage(float damage);
virtual void OnUpdate(sf::Time interval);
virtual bool initialize(Json::Value& root);
void SetDamage(float damage) {
m_damage = damage;
}
float GetDamage() const {
return m_damage;
}
void UpdateHealthbar();
private:
};
#endif /* LD32_ENEMY_HPP */