diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-06-11 11:38:49 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-06-11 11:38:49 -0400 |
commit | 879c2c04d9c3879f871cfe79f9b25fd23c5184b4 (patch) | |
tree | 70bf8773b18478af58ecd0877b6bb62a7279c094 /src/entity.h | |
parent | 11f4af82626b0e35c35606b327e4181c7c88f228 (diff) | |
download | therapy-879c2c04d9c3879f871cfe79f9b25fd23c5184b4.tar.gz therapy-879c2c04d9c3879f871cfe79f9b25fd23c5184b4.tar.bz2 therapy-879c2c04d9c3879f871cfe79f9b25fd23c5184b4.zip |
Wrote EntityManager
Diffstat (limited to 'src/entity.h')
-rw-r--r-- | src/entity.h | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/src/entity.h b/src/entity.h deleted file mode 100644 index 7f09f2d..0000000 --- a/src/entity.h +++ /dev/null | |||
@@ -1,64 +0,0 @@ | |||
1 | #ifndef ENTITY_H | ||
2 | #define ENTITY_H | ||
3 | |||
4 | #include <list> | ||
5 | #include "renderer.h" | ||
6 | |||
7 | class Game; | ||
8 | class Map; | ||
9 | class Entity; | ||
10 | class Component; | ||
11 | |||
12 | class Message { | ||
13 | public: | ||
14 | enum class Type { | ||
15 | walkLeft, | ||
16 | walkRight, | ||
17 | stopWalking, | ||
18 | setHorizontalVelocity, | ||
19 | setVerticalVelocity, | ||
20 | collision, | ||
21 | jump, | ||
22 | stopJump, | ||
23 | drop, | ||
24 | canDrop, | ||
25 | cantDrop, | ||
26 | die, | ||
27 | stopDying, | ||
28 | hitTheGround | ||
29 | }; | ||
30 | |||
31 | Message(Type type) : type(type) {} | ||
32 | |||
33 | Type type; | ||
34 | Entity* collisionEntity; | ||
35 | int dropAxis; | ||
36 | double velocity; | ||
37 | }; | ||
38 | |||
39 | class Entity { | ||
40 | public: | ||
41 | void addComponent(std::shared_ptr<Component> c); | ||
42 | void send(Game& game, const Message& msg); | ||
43 | void tick(Game& game, double dt); | ||
44 | void input(Game& game, int key, int action); | ||
45 | void render(Game& game, Texture& buffer); | ||
46 | void detectCollision(Game& game, Entity& collider, std::pair<double, double> old_position); | ||
47 | |||
48 | std::pair<double, double> position; | ||
49 | std::pair<int, int> size; | ||
50 | |||
51 | private: | ||
52 | std::list<std::shared_ptr<Component>> components; | ||
53 | }; | ||
54 | |||
55 | class Component { | ||
56 | public: | ||
57 | virtual void receive(Game&, Entity&, const Message&) {} | ||
58 | virtual void render(Game&, Entity&, Texture&) {} | ||
59 | virtual void tick(Game&, Entity&, double) {} | ||
60 | virtual void input(Game&, Entity&, int, int) {} | ||
61 | virtual void detectCollision(Game&, Entity&, Entity&, std::pair<double, double>) {} | ||
62 | }; | ||
63 | |||
64 | #endif | ||