diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-02-07 15:18:48 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-02-07 15:18:48 -0500 |
| commit | f9448d36db7c076f5091f70b7921dceddf63fdf9 (patch) | |
| tree | a67d47d3e45fee4c258ad968f0d7bec9d78747eb /src | |
| parent | da454bb943929ae649c09ca948e7c83644c35712 (diff) | |
| download | therapy-f9448d36db7c076f5091f70b7921dceddf63fdf9.tar.gz therapy-f9448d36db7c076f5091f70b7921dceddf63fdf9.tar.bz2 therapy-f9448d36db7c076f5091f70b7921dceddf63fdf9.zip | |
Inlined some components
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/controllable.cpp | 71 | ||||
| -rw-r--r-- | src/components/controllable.h | 108 | ||||
| -rw-r--r-- | src/components/droppable.cpp | 11 | ||||
| -rw-r--r-- | src/components/droppable.h | 19 | ||||
| -rw-r--r-- | src/components/ponderable.cpp | 41 | ||||
| -rw-r--r-- | src/components/ponderable.h | 68 | ||||
| -rw-r--r-- | src/components/transformable.cpp | 47 | ||||
| -rw-r--r-- | src/components/transformable.h | 78 |
8 files changed, 209 insertions, 234 deletions
| diff --git a/src/components/controllable.cpp b/src/components/controllable.cpp deleted file mode 100644 index a4d45f2..0000000 --- a/src/components/controllable.cpp +++ /dev/null | |||
| @@ -1,71 +0,0 @@ | |||
| 1 | #include "controllable.h" | ||
| 2 | |||
| 3 | int ControllableComponent::getLeftKey() const | ||
| 4 | { | ||
| 5 | return leftKey; | ||
| 6 | } | ||
| 7 | |||
| 8 | void ControllableComponent::setLeftKey(int k) | ||
| 9 | { | ||
| 10 | leftKey = k; | ||
| 11 | } | ||
| 12 | |||
| 13 | int ControllableComponent::getRightKey() const | ||
| 14 | { | ||
| 15 | return rightKey; | ||
| 16 | } | ||
| 17 | |||
| 18 | void ControllableComponent::setRightKey(int k) | ||
| 19 | { | ||
| 20 | rightKey = k; | ||
| 21 | } | ||
| 22 | |||
| 23 | int ControllableComponent::getJumpKey() const | ||
| 24 | { | ||
| 25 | return jumpKey; | ||
| 26 | } | ||
| 27 | |||
| 28 | void ControllableComponent::setJumpKey(int k) | ||
| 29 | { | ||
| 30 | jumpKey = k; | ||
| 31 | } | ||
| 32 | |||
| 33 | int ControllableComponent::getDropKey() const | ||
| 34 | { | ||
| 35 | return dropKey; | ||
| 36 | } | ||
| 37 | |||
| 38 | void ControllableComponent::setDropKey(int k) | ||
| 39 | { | ||
| 40 | dropKey = k; | ||
| 41 | } | ||
| 42 | |||
| 43 | bool ControllableComponent::isFrozen() const | ||
| 44 | { | ||
| 45 | return frozen; | ||
| 46 | } | ||
| 47 | |||
| 48 | void ControllableComponent::setFrozen(bool f) | ||
| 49 | { | ||
| 50 | frozen = f; | ||
| 51 | } | ||
| 52 | |||
| 53 | bool ControllableComponent::isHoldingLeft() const | ||
| 54 | { | ||
| 55 | return holdingLeft; | ||
| 56 | } | ||
| 57 | |||
| 58 | void ControllableComponent::setHoldingLeft(bool f) | ||
| 59 | { | ||
| 60 | holdingLeft = f; | ||
| 61 | } | ||
| 62 | |||
| 63 | bool ControllableComponent::isHoldingRight() const | ||
| 64 | { | ||
| 65 | return holdingRight; | ||
| 66 | } | ||
| 67 | |||
| 68 | void ControllableComponent::setHoldingRight(bool f) | ||
| 69 | { | ||
| 70 | holdingRight = f; | ||
| 71 | } | ||
| 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 | ||
| 7 | class ControllableComponent : public Component { | 7 | class ControllableComponent : public Component { |
| 8 | public: | 8 | public: |
| 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 | |||
| 80 | private: | ||
| 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 */ |
| diff --git a/src/components/droppable.cpp b/src/components/droppable.cpp deleted file mode 100644 index 534fd9a..0000000 --- a/src/components/droppable.cpp +++ /dev/null | |||
| @@ -1,11 +0,0 @@ | |||
| 1 | #include "droppable.h" | ||
| 2 | |||
| 3 | void DroppableComponent::setDroppable(bool can) | ||
| 4 | { | ||
| 5 | droppable = can; | ||
| 6 | } | ||
| 7 | |||
| 8 | bool DroppableComponent::isDroppable() const | ||
| 9 | { | ||
| 10 | return droppable; | ||
| 11 | } | ||
| diff --git a/src/components/droppable.h b/src/components/droppable.h index 83fcb9d..722c139 100644 --- a/src/components/droppable.h +++ b/src/components/droppable.h | |||
| @@ -4,12 +4,21 @@ | |||
| 4 | #include "component.h" | 4 | #include "component.h" |
| 5 | 5 | ||
| 6 | class DroppableComponent : public Component { | 6 | class DroppableComponent : public Component { |
| 7 | public: | 7 | public: |
| 8 | void setDroppable(bool can); | ||
| 9 | bool isDroppable() const; | ||
| 10 | 8 | ||
| 11 | private: | 9 | inline bool isDroppable() const |
| 12 | bool droppable = false; | 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; | ||
| 13 | }; | 22 | }; |
| 14 | 23 | ||
| 15 | #endif /* end of include guard: DROPPABLE_H_5DB254EF */ | 24 | #endif /* end of include guard: DROPPABLE_H_5DB254EF */ |
| diff --git a/src/components/ponderable.cpp b/src/components/ponderable.cpp deleted file mode 100644 index 2cfa6a6..0000000 --- a/src/components/ponderable.cpp +++ /dev/null | |||
| @@ -1,41 +0,0 @@ | |||
| 1 | #include "ponderable.h" | ||
| 2 | |||
| 3 | double PonderableComponent::getVelocityX() const | ||
| 4 | { | ||
| 5 | return velocityX; | ||
| 6 | } | ||
| 7 | |||
| 8 | void PonderableComponent::setVelocityX(double v) | ||
| 9 | { | ||
| 10 | velocityX = v; | ||
| 11 | } | ||
| 12 | |||
| 13 | double PonderableComponent::getVelocityY() const | ||
| 14 | { | ||
| 15 | return velocityY; | ||
| 16 | } | ||
| 17 | |||
| 18 | void PonderableComponent::setVelocityY(double v) | ||
| 19 | { | ||
| 20 | velocityY = v; | ||
| 21 | } | ||
| 22 | |||
| 23 | double PonderableComponent::getAccelX() const | ||
| 24 | { | ||
| 25 | return accelX; | ||
| 26 | } | ||
| 27 | |||
| 28 | void PonderableComponent::setAccelX(double v) | ||
| 29 | { | ||
| 30 | accelX = v; | ||
| 31 | } | ||
| 32 | |||
| 33 | double PonderableComponent::getAccelY() const | ||
| 34 | { | ||
| 35 | return accelY; | ||
| 36 | } | ||
| 37 | |||
| 38 | void PonderableComponent::setAccelY(double v) | ||
| 39 | { | ||
| 40 | accelY = v; | ||
| 41 | } | ||
| diff --git a/src/components/ponderable.h b/src/components/ponderable.h index c836d2a..80100d7 100644 --- a/src/components/ponderable.h +++ b/src/components/ponderable.h | |||
| @@ -4,21 +4,59 @@ | |||
| 4 | #include "component.h" | 4 | #include "component.h" |
| 5 | 5 | ||
| 6 | class PonderableComponent : public Component { | 6 | class PonderableComponent : public Component { |
| 7 | public: | 7 | public: |
| 8 | double getVelocityX() const; | 8 | |
| 9 | void setVelocityX(double v); | 9 | inline double getVelocityX() const |
| 10 | double getVelocityY() const; | 10 | { |
| 11 | void setVelocityY(double v); | 11 | return velX_; |
| 12 | double getAccelX() const; | 12 | } |
| 13 | void setAccelX(double v); | 13 | |
| 14 | double getAccelY() const; | 14 | inline void setVelocityX(double v) |
| 15 | void setAccelY(double v); | 15 | { |
| 16 | 16 | velX_ = v; | |
| 17 | private: | 17 | } |
| 18 | double velocityX = 0.0; | 18 | |
| 19 | double velocityY = 0.0; | 19 | inline double getVelocityY() const |
| 20 | double accelX = 0.0; | 20 | { |
| 21 | double accelY = 0.0; | 21 | return velY_; |
| 22 | } | ||
| 23 | |||
| 24 | inline void setVelocityY(double v) | ||
| 25 | { | ||
| 26 | velY_ = v; | ||
| 27 | } | ||
| 28 | |||
| 29 | inline double getAccelX() const | ||
| 30 | { | ||
| 31 | return accelX_; | ||
| 32 | } | ||
| 33 | |||
| 34 | inline void setAccelX(double v) | ||
| 35 | { | ||
| 36 | accelX_ = v; | ||
| 37 | } | ||
| 38 | |||
| 39 | inline double getAccelY() const | ||
| 40 | { | ||
| 41 | return accelY_; | ||
| 42 | } | ||
| 43 | |||
| 44 | inline void setAccelY(double v) | ||
| 45 | { | ||
| 46 | accelY_ = v; | ||
| 47 | } | ||
| 48 | |||
| 49 | inline state getState() const | ||
| 50 | { | ||
| 51 | return state_; | ||
| 52 | } | ||
| 53 | |||
| 54 | private: | ||
| 55 | |||
| 56 | double velX_ = 0.0; | ||
| 57 | double velY_ = 0.0; | ||
| 58 | double accelX_ = 0.0; | ||
| 59 | double accelY_ = 0.0; | ||
| 22 | }; | 60 | }; |
| 23 | 61 | ||
| 24 | #endif /* end of include guard: TANGIBLE_H_746DB3EE */ | 62 | #endif /* end of include guard: TANGIBLE_H_746DB3EE */ |
| diff --git a/src/components/transformable.cpp b/src/components/transformable.cpp deleted file mode 100644 index 89b1e5d..0000000 --- a/src/components/transformable.cpp +++ /dev/null | |||
| @@ -1,47 +0,0 @@ | |||
| 1 | #include "transformable.h" | ||
| 2 | |||
| 3 | TransformableComponent::TransformableComponent(double x, double y, int w, int h) | ||
| 4 | : x(x), y(y), w(w), h(h) | ||
| 5 | { | ||
| 6 | |||
| 7 | } | ||
| 8 | |||
| 9 | double TransformableComponent::getX() const | ||
| 10 | { | ||
| 11 | return x; | ||
| 12 | } | ||
| 13 | |||
| 14 | double TransformableComponent::getY() const | ||
| 15 | { | ||
| 16 | return y; | ||
| 17 | } | ||
| 18 | |||
| 19 | int TransformableComponent::getW() const | ||
| 20 | { | ||
| 21 | return w; | ||
| 22 | } | ||
| 23 | |||
| 24 | int TransformableComponent::getH() const | ||
| 25 | { | ||
| 26 | return h; | ||
| 27 | } | ||
| 28 | |||
| 29 | void TransformableComponent::setX(double v) | ||
| 30 | { | ||
| 31 | x = v; | ||
| 32 | } | ||
| 33 | |||
| 34 | void TransformableComponent::setY(double v) | ||
| 35 | { | ||
| 36 | y = v; | ||
| 37 | } | ||
| 38 | |||
| 39 | void TransformableComponent::setW(int v) | ||
| 40 | { | ||
| 41 | w = v; | ||
| 42 | } | ||
| 43 | |||
| 44 | void TransformableComponent::setH(int v) | ||
| 45 | { | ||
| 46 | h = v; | ||
| 47 | } | ||
| diff --git a/src/components/transformable.h b/src/components/transformable.h index 69f4f0e..6ed2637 100644 --- a/src/components/transformable.h +++ b/src/components/transformable.h | |||
| @@ -4,24 +4,66 @@ | |||
| 4 | #include "component.h" | 4 | #include "component.h" |
| 5 | 5 | ||
| 6 | class TransformableComponent : public Component { | 6 | class TransformableComponent : public Component { |
| 7 | public: | 7 | public: |
| 8 | TransformableComponent(double x, double y, int w, int h); | 8 | |
| 9 | 9 | TransformableComponent( | |
| 10 | double getX() const; | 10 | double x, |
| 11 | double getY() const; | 11 | double y, |
| 12 | int getW() const; | 12 | int w, |
| 13 | int getH() const; | 13 | int h) : |
| 14 | 14 | x_(x), | |
| 15 | void setX(double v); | 15 | y_(y), |
| 16 | void setY(double v); | 16 | w_(w), |
| 17 | void setW(int v); | 17 | h_(h) |
| 18 | void setH(int v); | 18 | { |
| 19 | 19 | } | |
| 20 | private: | 20 | |
| 21 | double x; | 21 | inline double getX() const |
| 22 | double y; | 22 | { |
| 23 | int w; | 23 | return x_; |
| 24 | int h; | 24 | } |
| 25 | |||
| 26 | inline void setX(double v) | ||
| 27 | { | ||
| 28 | x_ = v; | ||
| 29 | } | ||
| 30 | |||
| 31 | inline double getY() const | ||
| 32 | { | ||
| 33 | return y_; | ||
| 34 | } | ||
| 35 | |||
| 36 | inline void setY(double v) | ||
| 37 | { | ||
| 38 | y_ = v; | ||
| 39 | } | ||
| 40 | |||
| 41 | inline int getW() const | ||
| 42 | { | ||
| 43 | return w_; | ||
| 44 | } | ||
| 45 | |||
| 46 | inline void setW(int v) | ||
| 47 | { | ||
| 48 | w_ = v; | ||
| 49 | } | ||
| 50 | |||
| 51 | inline int getH() const | ||
| 52 | { | ||
| 53 | return h_; | ||
| 54 | } | ||
| 55 | |||
| 56 | inline void setH(int v) | ||
| 57 | { | ||
| 58 | h_ = v; | ||
| 59 | } | ||
| 60 | |||
| 61 | private: | ||
| 62 | |||
| 63 | double x_; | ||
| 64 | double y_; | ||
| 65 | int w_; | ||
| 66 | int h_; | ||
| 25 | }; | 67 | }; |
| 26 | 68 | ||
| 27 | #endif /* end of include guard: LOCATABLE_H_39E526CA */ | 69 | #endif /* end of include guard: LOCATABLE_H_39E526CA */ |
