diff options
Diffstat (limited to 'src/components/animatable.h')
-rw-r--r-- | src/components/animatable.h | 146 |
1 files changed, 72 insertions, 74 deletions
diff --git a/src/components/animatable.h b/src/components/animatable.h index ec72be0..1a678ba 100644 --- a/src/components/animatable.h +++ b/src/components/animatable.h | |||
@@ -8,88 +8,86 @@ | |||
8 | class AnimatableComponent : public Component { | 8 | class AnimatableComponent : public Component { |
9 | public: | 9 | public: |
10 | 10 | ||
11 | /** | ||
12 | * Constructor for initializing the animation set, because it is not default | ||
13 | * constructible. | ||
14 | */ | ||
11 | AnimatableComponent( | 15 | AnimatableComponent( |
12 | AnimationSet animationSet, | 16 | AnimationSet animationSet) : |
13 | std::string animation) : | 17 | animationSet(std::move(animationSet)) |
14 | animationSet_(std::move(animationSet)), | ||
15 | animation_(std::move(animation)) | ||
16 | { | 18 | { |
17 | } | 19 | } |
18 | 20 | ||
19 | inline size_t getFrame() const | 21 | /** |
20 | { | 22 | * The animation set that this entity will use -- an object describing the |
21 | return frame_; | 23 | * different animations that can be used to render the entity. |
22 | } | 24 | * |
23 | 25 | * @managed_by RealizingSystem | |
24 | inline void setFrame(size_t v) | 26 | */ |
25 | { | 27 | AnimationSet animationSet; |
26 | frame_ = v; | 28 | |
27 | } | 29 | /** |
28 | 30 | * The name of the currently active animation. | |
29 | inline size_t getCountdown() const | 31 | * |
30 | { | 32 | * @managed_by AnimatingSystem |
31 | return countdown_; | 33 | */ |
32 | } | 34 | std::string animation; |
33 | 35 | ||
34 | inline void setCountdown(size_t v) | 36 | /** |
35 | { | 37 | * For prototypes, the name of the original animation. |
36 | countdown_ = v; | 38 | * |
37 | } | 39 | * @managed_by RealizingSystem |
38 | 40 | */ | |
39 | inline const AnimationSet& getAnimationSet() const | 41 | std::string origAnimation; |
40 | { | 42 | |
41 | return animationSet_; | 43 | /** |
42 | } | 44 | * Helper method for accessing the currently active animation. |
43 | 45 | */ | |
44 | inline const Animation& getAnimation() const | 46 | inline const Animation& getAnimation() const |
45 | { | 47 | { |
46 | return animationSet_.getAnimation(animation_); | 48 | return animationSet.getAnimation(animation); |
47 | } | 49 | } |
48 | 50 | ||
49 | inline void setAnimation(std::string animation) | 51 | /** |
50 | { | 52 | * The frame of animation that is currently being rendered. |
51 | animation_ = std::move(animation); | 53 | * |
52 | } | 54 | * @managed_by AnimatingSystem |
53 | 55 | */ | |
54 | inline bool isFlickering() const | 56 | size_t frame = 0; |
55 | { | 57 | |
56 | return flickering_; | 58 | /** |
57 | } | 59 | * The amount of time (in game frames) before the animation is advanced. |
58 | 60 | * | |
59 | inline void setFlickering(bool v) | 61 | * @managed_by AnimatingSystem |
60 | { | 62 | */ |
61 | flickering_ = v; | 63 | size_t countdown = 0; |
62 | } | 64 | |
63 | 65 | /** | |
64 | inline size_t getFlickerTimer() const | 66 | * This option allows to give the sprite a "flickering" effect (as in, it is |
65 | { | 67 | * not rendered in some frames). |
66 | return flickerTimer_; | 68 | */ |
67 | } | 69 | bool flickering = false; |
68 | 70 | ||
69 | inline void setFlickerTimer(size_t v) | 71 | /** |
70 | { | 72 | * Used for the flickering effect. |
71 | flickerTimer_ = v; | 73 | * |
72 | } | 74 | * @managed_by AnimatingSystem |
73 | 75 | */ | |
74 | inline bool isFrozen() const | 76 | size_t flickerTimer = 0; |
75 | { | 77 | |
76 | return frozen_; | 78 | /** |
77 | } | 79 | * If enabled, this will prevent the sprite's animation from progressing (but |
78 | 80 | * will not affect things such as placement on screen and flickering). | |
79 | inline void setFrozen(bool v) | 81 | */ |
80 | { | 82 | bool frozen = false; |
81 | frozen_ = v; | 83 | |
82 | } | 84 | /** |
83 | 85 | * If this flag is disabled, the entity will be ignored by the animating | |
84 | private: | 86 | * system. |
85 | 87 | * | |
86 | AnimationSet animationSet_; | 88 | * @managed_by RealizingSystem |
87 | std::string animation_; | 89 | */ |
88 | size_t frame_ = 0; | 90 | bool active = false; |
89 | size_t countdown_ = 0; | ||
90 | bool flickering_ = false; | ||
91 | size_t flickerTimer_ = 0; | ||
92 | bool frozen_ = false; | ||
93 | }; | 91 | }; |
94 | 92 | ||
95 | #endif /* end of include guard: SPRITE_RENDERABLE_H_D3AACBBF */ | 93 | #endif /* end of include guard: SPRITE_RENDERABLE_H_D3AACBBF */ |