diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/droppable.h | 24 | ||||
-rw-r--r-- | src/components/orientable.h | 45 | ||||
-rw-r--r-- | src/components/ponderable.h | 17 |
3 files changed, 50 insertions, 36 deletions
diff --git a/src/components/droppable.h b/src/components/droppable.h deleted file mode 100644 index 722c139..0000000 --- a/src/components/droppable.h +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | #ifndef DROPPABLE_H_5DB254EF | ||
2 | #define DROPPABLE_H_5DB254EF | ||
3 | |||
4 | #include "component.h" | ||
5 | |||
6 | class DroppableComponent : public Component { | ||
7 | public: | ||
8 | |||
9 | inline bool isDroppable() const | ||
10 | { | ||
11 | return droppable_; | ||
12 | } | ||
13 | |||
14 | inline void setDroppable(bool can) | ||
15 | { | ||
16 | droppable_ = can; | ||
17 | } | ||
18 | |||
19 | private: | ||
20 | |||
21 | bool droppable_ = false; | ||
22 | }; | ||
23 | |||
24 | #endif /* end of include guard: DROPPABLE_H_5DB254EF */ | ||
diff --git a/src/components/orientable.h b/src/components/orientable.h index 8f56912..e356b78 100644 --- a/src/components/orientable.h +++ b/src/components/orientable.h | |||
@@ -6,6 +6,18 @@ | |||
6 | class OrientableComponent : public Component { | 6 | class OrientableComponent : public Component { |
7 | public: | 7 | public: |
8 | 8 | ||
9 | enum class WalkState { | ||
10 | still, | ||
11 | left, | ||
12 | right | ||
13 | }; | ||
14 | |||
15 | enum class DropState { | ||
16 | none, | ||
17 | ready, | ||
18 | active | ||
19 | }; | ||
20 | |||
9 | inline bool isFacingRight() const | 21 | inline bool isFacingRight() const |
10 | { | 22 | { |
11 | return facingRight_; | 23 | return facingRight_; |
@@ -16,9 +28,42 @@ public: | |||
16 | facingRight_ = v; | 28 | facingRight_ = v; |
17 | } | 29 | } |
18 | 30 | ||
31 | inline WalkState getWalkState() const | ||
32 | { | ||
33 | return walkState_; | ||
34 | } | ||
35 | |||
36 | inline void setWalkState(WalkState v) | ||
37 | { | ||
38 | walkState_ = v; | ||
39 | } | ||
40 | |||
41 | inline bool isJumping() const | ||
42 | { | ||
43 | return jumping_; | ||
44 | } | ||
45 | |||
46 | inline void setJumping(bool v) | ||
47 | { | ||
48 | jumping_ = v; | ||
49 | } | ||
50 | |||
51 | inline DropState getDropState() const | ||
52 | { | ||
53 | return dropState_; | ||
54 | } | ||
55 | |||
56 | inline void setDropState(DropState v) | ||
57 | { | ||
58 | dropState_ = v; | ||
59 | } | ||
60 | |||
19 | private: | 61 | private: |
20 | 62 | ||
21 | bool facingRight_ = false; | 63 | bool facingRight_ = false; |
64 | WalkState walkState_ = WalkState::still; | ||
65 | bool jumping_ = false; | ||
66 | DropState dropState_ = DropState::none; | ||
22 | }; | 67 | }; |
23 | 68 | ||
24 | #endif /* end of include guard: ORIENTABLE_H_EDB6C4A1 */ | 69 | #endif /* end of include guard: ORIENTABLE_H_EDB6C4A1 */ |
diff --git a/src/components/ponderable.h b/src/components/ponderable.h index ac759b6..e21cbab 100644 --- a/src/components/ponderable.h +++ b/src/components/ponderable.h | |||
@@ -11,13 +11,6 @@ public: | |||
11 | freefalling | 11 | freefalling |
12 | }; | 12 | }; |
13 | 13 | ||
14 | enum class State { | ||
15 | grounded, | ||
16 | jumping, | ||
17 | falling, | ||
18 | dropping | ||
19 | }; | ||
20 | |||
21 | PonderableComponent(Type type) : type_(type) | 14 | PonderableComponent(Type type) : type_(type) |
22 | { | 15 | { |
23 | } | 16 | } |
@@ -67,14 +60,14 @@ public: | |||
67 | accelY_ = v; | 60 | accelY_ = v; |
68 | } | 61 | } |
69 | 62 | ||
70 | inline State getState() const | 63 | inline bool isGrounded() const |
71 | { | 64 | { |
72 | return state_; | 65 | return grounded_; |
73 | } | 66 | } |
74 | 67 | ||
75 | inline void setState(State arg) | 68 | inline void setGrounded(bool v) |
76 | { | 69 | { |
77 | state_ = arg; | 70 | grounded_ = v; |
78 | } | 71 | } |
79 | 72 | ||
80 | private: | 73 | private: |
@@ -84,7 +77,7 @@ private: | |||
84 | double accelX_ = 0.0; | 77 | double accelX_ = 0.0; |
85 | double accelY_ = 0.0; | 78 | double accelY_ = 0.0; |
86 | Type type_ = Type::vacuumed; | 79 | Type type_ = Type::vacuumed; |
87 | State state_ = State::grounded; | 80 | bool grounded_ = false; |
88 | }; | 81 | }; |
89 | 82 | ||
90 | #endif /* end of include guard: TANGIBLE_H_746DB3EE */ | 83 | #endif /* end of include guard: TANGIBLE_H_746DB3EE */ |