diff options
Diffstat (limited to 'src/components/ponderable.h')
| -rw-r--r-- | src/components/ponderable.h | 151 |
1 files changed, 62 insertions, 89 deletions
| diff --git a/src/components/ponderable.h b/src/components/ponderable.h index 78af25f..fd7e775 100644 --- a/src/components/ponderable.h +++ b/src/components/ponderable.h | |||
| @@ -6,100 +6,73 @@ | |||
| 6 | class PonderableComponent : public Component { | 6 | class PonderableComponent : public Component { |
| 7 | public: | 7 | public: |
| 8 | 8 | ||
| 9 | /** | ||
| 10 | * List of different types of physical bodies. | ||
| 11 | * | ||
| 12 | * vacuumed - Default. | ||
| 13 | * freefalling - The body will be treated as if there were a downward force | ||
| 14 | * of gravity being exerted onto it. The body will also exhibit | ||
| 15 | * terminal velocity (that is, its downward velocity will be | ||
| 16 | * capped at a constant value). | ||
| 17 | */ | ||
| 9 | enum class Type { | 18 | enum class Type { |
| 10 | vacuumed, | 19 | vacuumed, |
| 11 | freefalling | 20 | freefalling |
| 12 | }; | 21 | }; |
| 13 | 22 | ||
| 14 | PonderableComponent(Type type) : type_(type) | 23 | /** |
| 15 | { | 24 | * Constructor for initializing the body type, which is a constant. |
| 16 | } | 25 | */ |
| 17 | 26 | PonderableComponent(Type type) : type(type) | |
| 18 | inline Type getType() const | 27 | { |
| 19 | { | 28 | } |
| 20 | return type_; | 29 | |
| 21 | } | 30 | /** |
| 22 | 31 | * The velocity of the body. | |
| 23 | inline double getVelocityX() const | 32 | */ |
| 24 | { | 33 | double velX = 0.0; |
| 25 | return velX_; | 34 | double velY = 0.0; |
| 26 | } | 35 | |
| 27 | 36 | /** | |
| 28 | inline void setVelocityX(double v) | 37 | * The acceleration of the body. |
| 29 | { | 38 | */ |
| 30 | velX_ = v; | 39 | double accelX = 0.0; |
| 31 | } | 40 | double accelY = 0.0; |
| 32 | 41 | ||
| 33 | inline double getVelocityY() const | 42 | /** |
| 34 | { | 43 | * The type of physical body that the entity is meant to assume. The body will |
| 35 | return velY_; | 44 | * be acted upon differently based on this. See the enumeration above for more |
| 36 | } | 45 | * details. |
| 37 | 46 | * | |
| 38 | inline void setVelocityY(double v) | 47 | * @managed_by PonderingSystem |
| 39 | { | 48 | */ |
| 40 | velY_ = v; | 49 | const Type type; |
| 41 | } | 50 | |
| 42 | 51 | /** | |
| 43 | inline double getAccelX() const | 52 | * Whether or not a freefalling body is in contact with the ground. |
| 44 | { | 53 | * |
| 45 | return accelX_; | 54 | * @managed_by PonderingSystem |
| 46 | } | 55 | */ |
| 47 | 56 | bool grounded = false; | |
| 48 | inline void setAccelX(double v) | 57 | |
| 49 | { | 58 | /** |
| 50 | accelX_ = v; | 59 | * If enabled, this will prevent the body from moving. |
| 51 | } | 60 | */ |
| 52 | 61 | bool frozen = false; | |
| 53 | inline double getAccelY() const | 62 | |
| 54 | { | 63 | /** |
| 55 | return accelY_; | 64 | * If disabled, collision detection for this body will not be performed and |
| 56 | } | 65 | * other bodies will ignore it. |
| 57 | 66 | */ | |
| 58 | inline void setAccelY(double v) | 67 | bool collidable = true; |
| 59 | { | 68 | |
| 60 | accelY_ = v; | 69 | /** |
| 61 | } | 70 | * If this flag is disabled, the entity will be ignored by the pondering |
| 62 | 71 | * system. | |
| 63 | inline bool isGrounded() const | 72 | * |
| 64 | { | 73 | * @managed_by RealizingSystem |
| 65 | return grounded_; | 74 | */ |
| 66 | } | 75 | bool active = false; |
| 67 | |||
| 68 | inline void setGrounded(bool v) | ||
| 69 | { | ||
| 70 | grounded_ = v; | ||
| 71 | } | ||
| 72 | |||
| 73 | inline bool isFrozen() const | ||
| 74 | { | ||
| 75 | return frozen_; | ||
| 76 | } | ||
| 77 | |||
| 78 | inline void setFrozen(bool v) | ||
| 79 | { | ||
| 80 | frozen_ = v; | ||
| 81 | } | ||
| 82 | |||
| 83 | inline bool isCollidable() const | ||
| 84 | { | ||
| 85 | return collidable_; | ||
| 86 | } | ||
| 87 | |||
| 88 | inline void setCollidable(bool v) | ||
| 89 | { | ||
| 90 | collidable_ = v; | ||
| 91 | } | ||
| 92 | |||
| 93 | private: | ||
| 94 | |||
| 95 | double velX_ = 0.0; | ||
| 96 | double velY_ = 0.0; | ||
| 97 | double accelX_ = 0.0; | ||
| 98 | double accelY_ = 0.0; | ||
| 99 | Type type_ = Type::vacuumed; | ||
| 100 | bool grounded_ = false; | ||
| 101 | bool frozen_ = false; | ||
| 102 | bool collidable_ = true; | ||
| 103 | }; | 76 | }; |
| 104 | 77 | ||
| 105 | #endif /* end of include guard: TANGIBLE_H_746DB3EE */ | 78 | #endif /* end of include guard: TANGIBLE_H_746DB3EE */ |
