diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-02-18 15:25:52 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-02-18 15:25:52 -0500 |
| commit | e4e2f2d2a7b6a282b9618aa0004d9453936f43c6 (patch) | |
| tree | de1653dc8b5992420147f28d9fb4de052ea1845f /src/components | |
| parent | e16fb5be90c889c371cbb0ca2444735c2e12073c (diff) | |
| download | therapy-e4e2f2d2a7b6a282b9618aa0004d9453936f43c6.tar.gz therapy-e4e2f2d2a7b6a282b9618aa0004d9453936f43c6.tar.bz2 therapy-e4e2f2d2a7b6a282b9618aa0004d9453936f43c6.zip | |
Added player death and event scheduling
Also added ability to make sprites flicker, to freeze physics for an entity, and to freeze progression of a sprite's animation loop.
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/animatable.h | 33 | ||||
| -rw-r--r-- | src/components/playable.h | 9 | ||||
| -rw-r--r-- | src/components/ponderable.h | 22 | ||||
| -rw-r--r-- | src/components/schedulable.h | 21 |
4 files changed, 85 insertions, 0 deletions
| diff --git a/src/components/animatable.h b/src/components/animatable.h index ed0133e..ec72be0 100644 --- a/src/components/animatable.h +++ b/src/components/animatable.h | |||
| @@ -51,12 +51,45 @@ public: | |||
| 51 | animation_ = std::move(animation); | 51 | animation_ = std::move(animation); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | inline bool isFlickering() const | ||
| 55 | { | ||
| 56 | return flickering_; | ||
| 57 | } | ||
| 58 | |||
| 59 | inline void setFlickering(bool v) | ||
| 60 | { | ||
| 61 | flickering_ = v; | ||
| 62 | } | ||
| 63 | |||
| 64 | inline size_t getFlickerTimer() const | ||
| 65 | { | ||
| 66 | return flickerTimer_; | ||
| 67 | } | ||
| 68 | |||
| 69 | inline void setFlickerTimer(size_t v) | ||
| 70 | { | ||
| 71 | flickerTimer_ = v; | ||
| 72 | } | ||
| 73 | |||
| 74 | inline bool isFrozen() const | ||
| 75 | { | ||
| 76 | return frozen_; | ||
| 77 | } | ||
| 78 | |||
| 79 | inline void setFrozen(bool v) | ||
| 80 | { | ||
| 81 | frozen_ = v; | ||
| 82 | } | ||
| 83 | |||
| 54 | private: | 84 | private: |
| 55 | 85 | ||
| 56 | AnimationSet animationSet_; | 86 | AnimationSet animationSet_; |
| 57 | std::string animation_; | 87 | std::string animation_; |
| 58 | size_t frame_ = 0; | 88 | size_t frame_ = 0; |
| 59 | size_t countdown_ = 0; | 89 | size_t countdown_ = 0; |
| 90 | bool flickering_ = false; | ||
| 91 | size_t flickerTimer_ = 0; | ||
| 92 | bool frozen_ = false; | ||
| 60 | }; | 93 | }; |
| 61 | 94 | ||
| 62 | #endif /* end of include guard: SPRITE_RENDERABLE_H_D3AACBBF */ | 95 | #endif /* end of include guard: SPRITE_RENDERABLE_H_D3AACBBF */ |
| diff --git a/src/components/playable.h b/src/components/playable.h index a6e71b0..86a7ee7 100644 --- a/src/components/playable.h +++ b/src/components/playable.h | |||
| @@ -2,14 +2,23 @@ | |||
| 2 | #define PLAYABLE_H_DDC566C3 | 2 | #define PLAYABLE_H_DDC566C3 |
| 3 | 3 | ||
| 4 | #include "component.h" | 4 | #include "component.h" |
| 5 | #include <functional> | ||
| 5 | 6 | ||
| 6 | class PlayableComponent : public Component { | 7 | class PlayableComponent : public Component { |
| 7 | public: | 8 | public: |
| 8 | 9 | ||
| 10 | using MapChangeCallback = std::function<void()>; | ||
| 11 | |||
| 9 | bool changingMap = false; | 12 | bool changingMap = false; |
| 10 | int newMapId = -1; | 13 | int newMapId = -1; |
| 11 | double newMapX = 0; | 14 | double newMapX = 0; |
| 12 | double newMapY = 0; | 15 | double newMapY = 0; |
| 16 | MapChangeCallback newMapCallback; | ||
| 17 | |||
| 18 | int checkpointMapId = -1; | ||
| 19 | double checkpointX = 0; | ||
| 20 | double checkpointY = 0; | ||
| 21 | |||
| 13 | }; | 22 | }; |
| 14 | 23 | ||
| 15 | #endif /* end of include guard: PLAYABLE_H_DDC566C3 */ | 24 | #endif /* end of include guard: PLAYABLE_H_DDC566C3 */ |
| diff --git a/src/components/ponderable.h b/src/components/ponderable.h index e21cbab..78af25f 100644 --- a/src/components/ponderable.h +++ b/src/components/ponderable.h | |||
| @@ -70,6 +70,26 @@ public: | |||
| 70 | grounded_ = v; | 70 | grounded_ = v; |
| 71 | } | 71 | } |
| 72 | 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 | |||
| 73 | private: | 93 | private: |
| 74 | 94 | ||
| 75 | double velX_ = 0.0; | 95 | double velX_ = 0.0; |
| @@ -78,6 +98,8 @@ private: | |||
| 78 | double accelY_ = 0.0; | 98 | double accelY_ = 0.0; |
| 79 | Type type_ = Type::vacuumed; | 99 | Type type_ = Type::vacuumed; |
| 80 | bool grounded_ = false; | 100 | bool grounded_ = false; |
| 101 | bool frozen_ = false; | ||
| 102 | bool collidable_ = true; | ||
| 81 | }; | 103 | }; |
| 82 | 104 | ||
| 83 | #endif /* end of include guard: TANGIBLE_H_746DB3EE */ | 105 | #endif /* end of include guard: TANGIBLE_H_746DB3EE */ |
| diff --git a/src/components/schedulable.h b/src/components/schedulable.h new file mode 100644 index 0000000..a92bbba --- /dev/null +++ b/src/components/schedulable.h | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | #ifndef SCHEDULABLE_H_1DA3FA2A | ||
| 2 | #define SCHEDULABLE_H_1DA3FA2A | ||
| 3 | |||
| 4 | #include "component.h" | ||
| 5 | #include <tuple> | ||
| 6 | #include <list> | ||
| 7 | #include <functional> | ||
| 8 | #include "entity_manager.h" | ||
| 9 | |||
| 10 | class SchedulableComponent : public Component { | ||
| 11 | public: | ||
| 12 | |||
| 13 | using id_type = EntityManager::id_type; | ||
| 14 | |||
| 15 | using Callback = std::function<void(id_type)>; | ||
| 16 | using Action = std::tuple<double, Callback>; | ||
| 17 | |||
| 18 | std::list<Action> actions; | ||
| 19 | }; | ||
| 20 | |||
| 21 | #endif /* end of include guard: SCHEDULABLE_H_1DA3FA2A */ | ||
