summary refs log tree commit diff stats
path: root/src/components/mappable.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/mappable.h')
-rw-r--r--src/components/mappable.h146
1 files changed, 146 insertions, 0 deletions
diff --git a/src/components/mappable.h b/src/components/mappable.h new file mode 100644 index 0000000..7530919 --- /dev/null +++ b/src/components/mappable.h
@@ -0,0 +1,146 @@
1#ifndef MAPPABLE_H_0B0316FB
2#define MAPPABLE_H_0B0316FB
3
4#include <map>
5#include "component.h"
6#include "renderer.h"
7#include "map.h"
8
9class MappableComponent : public Component {
10public:
11
12 class Boundary {
13 public:
14
15 enum class Type {
16 wall,
17 wrap,
18 teleport,
19 reverse,
20 platform,
21 danger
22 };
23
24 Boundary(
25 double axis,
26 double lower,
27 double upper,
28 Type type) :
29 axis_(axis),
30 lower_(lower),
31 upper_(upper),
32 type_(type)
33 {
34 }
35
36 inline double getAxis() const
37 {
38 return axis_;
39 }
40
41 inline double getLower() const
42 {
43 return lower_;
44 }
45
46 inline double getUpper() const
47 {
48 return upper_;
49 }
50
51 inline Type getType() const
52 {
53 return type_;
54 }
55
56 private:
57
58 double axis_;
59 double lower_;
60 double upper_;
61 Type type_;
62 };
63
64 MappableComponent(
65 Texture tileset,
66 Texture font) :
67 tileset_(std::move(tileset)),
68 font_(std::move(font))
69 {
70 }
71
72 using asc_boundaries_type =
73 std::multimap<
74 double,
75 Boundary,
76 std::less<double>>;
77
78 using desc_boundaries_type =
79 std::multimap<
80 double,
81 Boundary,
82 std::greater<double>>;
83
84 inline size_t getMapId() const
85 {
86 return mapId_;
87 }
88
89 inline void setMapId(size_t v)
90 {
91 mapId_ = v;
92 }
93
94 inline desc_boundaries_type& getLeftBoundaries()
95 {
96 return leftBoundaries_;
97 }
98
99 inline asc_boundaries_type& getRightBoundaries()
100 {
101 return rightBoundaries_;
102 }
103
104 inline desc_boundaries_type& getUpBoundaries()
105 {
106 return upBoundaries_;
107 }
108
109 inline asc_boundaries_type& getDownBoundaries()
110 {
111 return downBoundaries_;
112 }
113
114 inline const Texture& getTileset() const
115 {
116 return tileset_;
117 }
118
119 inline void setTileset(Texture v)
120 {
121 tileset_ = std::move(v);
122 }
123
124 inline const Texture& getFont() const
125 {
126 return font_;
127 }
128
129 inline void setFont(Texture v)
130 {
131 font_ = std::move(v);
132 }
133
134private:
135
136 size_t mapId_ = -1;
137
138 desc_boundaries_type leftBoundaries_;
139 asc_boundaries_type rightBoundaries_;
140 desc_boundaries_type upBoundaries_;
141 asc_boundaries_type downBoundaries_;
142 Texture tileset_;
143 Texture font_;
144};
145
146#endif /* end of include guard: MAPPABLE_H_0B0316FB */