summary refs log tree commit diff stats
path: root/src/components
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-02-12 16:39:49 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-02-12 16:39:49 -0500
commit5cc80ec58ea5bd66456f6f5286fa5f26d3fe702b (patch)
tree283cef0e95f237e70892e8b90c841f971cb61fd9 /src/components
parent77be863f4f15d2481a64e4e8dadb4060a6e4e590 (diff)
downloadtherapy-5cc80ec58ea5bd66456f6f5286fa5f26d3fe702b.tar.gz
therapy-5cc80ec58ea5bd66456f6f5286fa5f26d3fe702b.tar.bz2
therapy-5cc80ec58ea5bd66456f6f5286fa5f26d3fe702b.zip
Abstracted behavior related to "orientable" entities
A lot of the stuff that ControllingSystem did to control the player character was moved into the new OrientingSystem. This is so that the player, or any player-like entities, can also be controlled by AI, with the underlying behavior being delegated in the same way as if the player were being controlled by the user.

Fixed the issue where, if the player were blocked while moving horizontally, they would remain blocked even if vertical movement were to remove the collision.

Fixed cases of the player animating incorrectly after performing certain movements.
Diffstat (limited to 'src/components')
-rw-r--r--src/components/droppable.h24
-rw-r--r--src/components/orientable.h45
-rw-r--r--src/components/ponderable.h17
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
6class DroppableComponent : public Component {
7public:
8
9 inline bool isDroppable() const
10 {
11 return droppable_;
12 }
13
14 inline void setDroppable(bool can)
15 {
16 droppable_ = can;
17 }
18
19private:
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 @@
6class OrientableComponent : public Component { 6class OrientableComponent : public Component {
7public: 7public:
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
19private: 61private:
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
80private: 73private:
@@ -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 */