summary refs log tree commit diff stats
path: root/src/components
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-04-21 14:50:52 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-04-21 14:50:52 -0400
commit8142a9c87a13cecc7a3698e877f24d89f128c074 (patch)
treecbee6ae85c5c674dd313c7cfe1420477ee55ca95 /src/components
parent0f70db34d9b47de55b00c558ac3c445f30b7b6a5 (diff)
downloadtherapy-8142a9c87a13cecc7a3698e877f24d89f128c074.tar.gz
therapy-8142a9c87a13cecc7a3698e877f24d89f128c074.tar.bz2
therapy-8142a9c87a13cecc7a3698e877f24d89f128c074.zip
Started working on prototype objects proto-objs
Diffstat (limited to 'src/components')
-rw-r--r--src/components/mappable.h6
-rw-r--r--src/components/playable.h2
-rw-r--r--src/components/ponderable.h44
3 files changed, 47 insertions, 5 deletions
diff --git a/src/components/mappable.h b/src/components/mappable.h index 633cdf4..e26326d 100644 --- a/src/components/mappable.h +++ b/src/components/mappable.h
@@ -125,6 +125,11 @@ public:
125 font_ = std::move(v); 125 font_ = std::move(v);
126 } 126 }
127 127
128 inline std::map<size_t, id_type>& getInstances()
129 {
130 return instances_;
131 }
132
128private: 133private:
129 134
130 size_t mapId_ = -1; 135 size_t mapId_ = -1;
@@ -135,6 +140,7 @@ private:
135 asc_boundaries_type downBoundaries_; 140 asc_boundaries_type downBoundaries_;
136 Texture tileset_; 141 Texture tileset_;
137 Texture font_; 142 Texture font_;
143 std::map<size_t, id_type> instances_;
138}; 144};
139 145
140#endif /* end of include guard: MAPPABLE_H_0B0316FB */ 146#endif /* end of include guard: MAPPABLE_H_0B0316FB */
diff --git a/src/components/playable.h b/src/components/playable.h index 86a7ee7..0d91929 100644 --- a/src/components/playable.h +++ b/src/components/playable.h
@@ -18,6 +18,8 @@ public:
18 int checkpointMapId = -1; 18 int checkpointMapId = -1;
19 double checkpointX = 0; 19 double checkpointX = 0;
20 double checkpointY = 0; 20 double checkpointY = 0;
21 bool checkpointObjectActivated = false;
22 size_t checkpointObjectIndex = 0;
21 23
22}; 24};
23 25
diff --git a/src/components/ponderable.h b/src/components/ponderable.h index 78af25f..da509a2 100644 --- a/src/components/ponderable.h +++ b/src/components/ponderable.h
@@ -2,22 +2,44 @@
2#define TANGIBLE_H_746DB3EE 2#define TANGIBLE_H_746DB3EE
3 3
4#include "component.h" 4#include "component.h"
5#include <functional>
6#include <array>
7
8class Game;
5 9
6class PonderableComponent : public Component { 10class PonderableComponent : public Component {
7public: 11public:
8 12
9 enum class Type { 13 enum class BodyType {
10 vacuumed, 14 vacuumed,
11 freefalling 15 freefalling
12 }; 16 };
13 17
14 PonderableComponent(Type type) : type_(type) 18 enum class ColliderType {
19 player,
20 event
21 };
22
23 static const size_t COLLIDER_TYPES = 2;
24
25 PonderableComponent(
26 BodyType bodyType,
27 ColliderType colliderType) :
28 bodyType_(bodyType),
29 colliderType_(colliderType)
30 {
31 }
32
33 using event_callback_type = std::function<void(Game& game)>;
34
35 inline BodyType getBodyType() const
15 { 36 {
37 return bodyType_;
16 } 38 }
17 39
18 inline Type getType() const 40 inline ColliderType getColliderType() const
19 { 41 {
20 return type_; 42 return colliderType_;
21 } 43 }
22 44
23 inline double getVelocityX() const 45 inline double getVelocityX() const
@@ -90,16 +112,28 @@ public:
90 collidable_ = v; 112 collidable_ = v;
91 } 113 }
92 114
115 inline const event_callback_type& getEventCallback(ColliderType v) const
116 {
117 return eventCallbacks_[static_cast<size_t>(v)];
118 }
119
120 inline void setEventCallback(ColliderType v, event_callback_type callback)
121 {
122 eventCallbacks_[static_cast<size_t>(v)] = std::move(callback);
123 }
124
93private: 125private:
94 126
95 double velX_ = 0.0; 127 double velX_ = 0.0;
96 double velY_ = 0.0; 128 double velY_ = 0.0;
97 double accelX_ = 0.0; 129 double accelX_ = 0.0;
98 double accelY_ = 0.0; 130 double accelY_ = 0.0;
99 Type type_ = Type::vacuumed; 131 BodyType bodyType_;
132 ColliderType colliderType_;
100 bool grounded_ = false; 133 bool grounded_ = false;
101 bool frozen_ = false; 134 bool frozen_ = false;
102 bool collidable_ = true; 135 bool collidable_ = true;
136 std::array<event_callback_type, COLLIDER_TYPES> eventCallbacks_;
103}; 137};
104 138
105#endif /* end of include guard: TANGIBLE_H_746DB3EE */ 139#endif /* end of include guard: TANGIBLE_H_746DB3EE */