summary refs log tree commit diff stats
path: root/src/components/controllable.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/controllable.h')
-rw-r--r--src/components/controllable.h108
1 files changed, 82 insertions, 26 deletions
diff --git a/src/components/controllable.h b/src/components/controllable.h index baccf13..fa78c8b 100644 --- a/src/components/controllable.h +++ b/src/components/controllable.h
@@ -5,32 +5,88 @@
5#include "renderer.h" 5#include "renderer.h"
6 6
7class ControllableComponent : public Component { 7class ControllableComponent : public Component {
8 public: 8public:
9 int getLeftKey() const; 9
10 void setLeftKey(int k); 10 inline int getLeftKey() const
11 int getRightKey() const; 11 {
12 void setRightKey(int k); 12 return leftKey_;
13 int getJumpKey() const; 13 }
14 void setJumpKey(int k); 14
15 int getDropKey() const; 15 inline void setLeftKey(int k)
16 void setDropKey(int k); 16 {
17 17 leftKey_ = k;
18 bool isFrozen() const; 18 }
19 void setFrozen(bool f); 19
20 bool isHoldingLeft() const; 20 inline int getRightKey() const
21 void setHoldingLeft(bool f); 21 {
22 bool isHoldingRight() const; 22 return rightKey_;
23 void setHoldingRight(bool f); 23 }
24 24
25 private: 25 inline void setRightKey(int k)
26 int leftKey = GLFW_KEY_LEFT; 26 {
27 int rightKey = GLFW_KEY_RIGHT; 27 rightKey_ = k;
28 int jumpKey = GLFW_KEY_UP; 28 }
29 int dropKey = GLFW_KEY_DOWN; 29
30 30 inline int getJumpKey() const
31 bool frozen = false; 31 {
32 bool holdingLeft = false; 32 return jumpKey_;
33 bool holdingRight = false; 33 }
34
35 inline void setJumpKey(int k)
36 {
37 jumpKey_ = k;
38 }
39
40 inline int getDropKey() const
41 {
42 return dropKey_;
43 }
44
45 inline void setDropKey(int k)
46 {
47 dropKey_ = k;
48 }
49
50 inline bool isFrozen() const
51 {
52 return frozen_;
53 }
54
55 inline void setFrozen(bool f)
56 {
57 frozen_ = f;
58 }
59
60 inline bool isHoldingLeft() const
61 {
62 return holdingLeft_;
63 }
64
65 inline void setHoldingLeft(bool f)
66 {
67 holdingLeft_ = f;
68 }
69
70 inline bool isHoldingRight() const
71 {
72 return holdingRight_;
73 }
74
75 inline void setHoldingRight(bool f)
76 {
77 holdingRight_ = f;
78 }
79
80private:
81
82 int leftKey_ = GLFW_KEY_LEFT;
83 int rightKey_ = GLFW_KEY_RIGHT;
84 int jumpKey_ = GLFW_KEY_UP;
85 int dropKey_ = GLFW_KEY_DOWN;
86
87 bool frozen_ = false;
88 bool holdingLeft_ = false;
89 bool holdingRight_ = false;
34}; 90};
35 91
36#endif /* end of include guard: CONTROLLABLE_H_4E0B85B4 */ 92#endif /* end of include guard: CONTROLLABLE_H_4E0B85B4 */