diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-14 19:25:23 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-14 19:25:23 -0400 |
commit | 6b1dcc5df51df4a2d8b724187eb1bcdb4fd9df8b (patch) | |
tree | 0a884ddd12b4e5b0afcc9c4ecaea5ecc73605b57 /src/components/map_collision.h | |
parent | d9349f10d6d1972e87aea76d502703fae128a0e5 (diff) | |
download | therapy-6b1dcc5df51df4a2d8b724187eb1bcdb4fd9df8b.tar.gz therapy-6b1dcc5df51df4a2d8b724187eb1bcdb4fd9df8b.tar.bz2 therapy-6b1dcc5df51df4a2d8b724187eb1bcdb4fd9df8b.zip |
Added sound when you hit the ground
Also split up components.cpp into files for each class, fixed a bug concerning falling off the screen when you change maps, and converted collision data into doubles.
Diffstat (limited to 'src/components/map_collision.h')
-rw-r--r-- | src/components/map_collision.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/components/map_collision.h b/src/components/map_collision.h new file mode 100644 index 0000000..3b718b6 --- /dev/null +++ b/src/components/map_collision.h | |||
@@ -0,0 +1,46 @@ | |||
1 | #ifndef MAP_COLLISION_H | ||
2 | #define MAP_COLLISION_H | ||
3 | |||
4 | #include "entity.h" | ||
5 | #include <list> | ||
6 | |||
7 | class Map; | ||
8 | class Game; | ||
9 | |||
10 | class MapCollisionComponent : public Component { | ||
11 | public: | ||
12 | MapCollisionComponent(const Map& map); | ||
13 | void detectCollision(Game& game, Entity& entity, Entity& collider, std::pair<double, double> old_position); | ||
14 | |||
15 | private: | ||
16 | enum class Direction { | ||
17 | up, left, down, right | ||
18 | }; | ||
19 | |||
20 | struct Collision { | ||
21 | enum class Type { | ||
22 | wall, | ||
23 | wrap, | ||
24 | teleport, | ||
25 | reverse, | ||
26 | platform, | ||
27 | danger | ||
28 | }; | ||
29 | |||
30 | double axis; | ||
31 | double lower; | ||
32 | double upper; | ||
33 | Type type; | ||
34 | }; | ||
35 | |||
36 | void addCollision(double axis, double lower, double upper, Direction dir, Collision::Type type); | ||
37 | void processCollision(Game& game, Entity& collider, Collision collision, Direction dir, std::pair<double, double> old_position); | ||
38 | |||
39 | std::list<Collision> left_collisions; | ||
40 | std::list<Collision> right_collisions; | ||
41 | std::list<Collision> up_collisions; | ||
42 | std::list<Collision> down_collisions; | ||
43 | const Map& map; | ||
44 | }; | ||
45 | |||
46 | #endif | ||