diff options
Diffstat (limited to 'src/collision.h')
-rw-r--r-- | src/collision.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/collision.h b/src/collision.h new file mode 100644 index 0000000..e5371f8 --- /dev/null +++ b/src/collision.h | |||
@@ -0,0 +1,81 @@ | |||
1 | #ifndef COLLISION_H_53D84877 | ||
2 | #define COLLISION_H_53D84877 | ||
3 | |||
4 | #include "entity_manager.h" | ||
5 | #include "direction.h" | ||
6 | |||
7 | class Collision { | ||
8 | public: | ||
9 | |||
10 | using id_type = EntityManager::id_type; | ||
11 | |||
12 | // Types are defined in descending priority order | ||
13 | enum class Type { | ||
14 | wall, | ||
15 | platform, | ||
16 | adjacency, | ||
17 | warp, | ||
18 | danger | ||
19 | }; | ||
20 | |||
21 | Collision( | ||
22 | id_type collider, | ||
23 | Direction dir, | ||
24 | Type type, | ||
25 | int axis, | ||
26 | double lower, | ||
27 | double upper) : | ||
28 | collider_(collider), | ||
29 | dir_(dir), | ||
30 | type_(type), | ||
31 | axis_(axis), | ||
32 | lower_(lower), | ||
33 | upper_(upper) | ||
34 | { | ||
35 | } | ||
36 | |||
37 | inline id_type getCollider() const | ||
38 | { | ||
39 | return collider_; | ||
40 | } | ||
41 | |||
42 | inline Direction getDirection() const | ||
43 | { | ||
44 | return dir_; | ||
45 | } | ||
46 | |||
47 | inline Type getType() const | ||
48 | { | ||
49 | return type_; | ||
50 | } | ||
51 | |||
52 | inline int getAxis() const | ||
53 | { | ||
54 | return axis_; | ||
55 | } | ||
56 | |||
57 | inline double getLower() const | ||
58 | { | ||
59 | return lower_; | ||
60 | } | ||
61 | |||
62 | inline double getUpper() const | ||
63 | { | ||
64 | return upper_; | ||
65 | } | ||
66 | |||
67 | bool operator<(const Collision& other) const; | ||
68 | |||
69 | bool isColliding(double x, double y, int w, int h) const; | ||
70 | |||
71 | private: | ||
72 | |||
73 | id_type collider_; | ||
74 | Direction dir_; | ||
75 | Type type_; | ||
76 | int axis_; | ||
77 | double lower_; | ||
78 | double upper_; | ||
79 | }; | ||
80 | |||
81 | #endif /* end of include guard: COLLISION_H_53D84877 */ | ||