-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentity.h
95 lines (81 loc) · 1.92 KB
/
entity.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#pragma once
#ifndef ENTITY_H_INCLUDED
#include <SFML/Graphics.hpp>
#include "animation.h"
#include "inventory.h"
#include "program_const.h"
#include "res.h"
#include "square.h"
#include "square_map.h"
#include "utils.h"
class Entity
{
protected:
Animation m_animation;
sf::Sprite m_sprite;
sf::Vector2<double> m_square_pos;
bool m_top_layer;
SquareMap* m_square_map;
// Stats
ItemStack m_loot;
int m_max_hp;
int m_hp;
// Methods
virtual void collision_update(void);
virtual void update_sprite(void);
virtual void on_death(void) {};
public:
Entity(void)
{
m_square_map = nullptr;
m_top_layer = false;
m_hp = 200;
m_max_hp = 200;
};
virtual void update(void) {};
virtual ~Entity(void) {};
virtual void hit(Entity* source, int dmg);
// Const
virtual void draw(sf::RenderWindow& window) const {};
virtual void draw_hp_bar(sf::RenderWindow& window) const;
virtual sf::Vector2<double> get_square_pos(void) const;
virtual bool is_mouseOn(sf::Vector2f mouse_pos) const;
virtual bool is_inWindow(sf::FloatRect draw_zone) const;
virtual ItemStack get_loot(void) const
{
return m_loot;
}
virtual bool is_dead(void) const
{
return m_hp <= 0;
}
virtual bool is_top_layer(void) const
{
return m_top_layer;
}
};
class Player : public Entity
{
sf::Vector2i m_direction;
Utils::TimeCounter m_counter;
Inventory m_inventory;
public:
Player(void) {};
Player(SquareMap* square_map, TextureGroup player_texture_group, sf::Vector2i pos);
virtual void update(void);
void nonticked_update(void);
void give_items(ItemStack items);
Inventory* get_inventory(void);
virtual void draw(sf::RenderWindow& window) const;
virtual ~Player(void) {};
};
class Tree : public Entity
{
virtual void on_death(void);
public:
Tree(void) {};
Tree(SquareMap* square_map, TextureGroup tree_texture_group, sf::Vector2i pos);
virtual void draw(sf::RenderWindow& window) const;
virtual ~Tree(void) {};
};
#endif // !ENTITY_H_INCLUDED