diff options
Diffstat (limited to 'src/components/animatable.h')
-rw-r--r-- | src/components/animatable.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/components/animatable.h b/src/components/animatable.h new file mode 100644 index 0000000..ed0133e --- /dev/null +++ b/src/components/animatable.h | |||
@@ -0,0 +1,62 @@ | |||
1 | #ifndef SPRITE_RENDERABLE_H_D3AACBBF | ||
2 | #define SPRITE_RENDERABLE_H_D3AACBBF | ||
3 | |||
4 | #include "component.h" | ||
5 | #include "animation.h" | ||
6 | #include <string> | ||
7 | |||
8 | class AnimatableComponent : public Component { | ||
9 | public: | ||
10 | |||
11 | AnimatableComponent( | ||
12 | AnimationSet animationSet, | ||
13 | std::string animation) : | ||
14 | animationSet_(std::move(animationSet)), | ||
15 | animation_(std::move(animation)) | ||
16 | { | ||
17 | } | ||
18 | |||
19 | inline size_t getFrame() const | ||
20 | { | ||
21 | return frame_; | ||
22 | } | ||
23 | |||
24 | inline void setFrame(size_t v) | ||
25 | { | ||
26 | frame_ = v; | ||
27 | } | ||
28 | |||
29 | inline size_t getCountdown() const | ||
30 | { | ||
31 | return countdown_; | ||
32 | } | ||
33 | |||
34 | inline void setCountdown(size_t v) | ||
35 | { | ||
36 | countdown_ = v; | ||
37 | } | ||
38 | |||
39 | inline const AnimationSet& getAnimationSet() const | ||
40 | { | ||
41 | return animationSet_; | ||
42 | } | ||
43 | |||
44 | inline const Animation& getAnimation() const | ||
45 | { | ||
46 | return animationSet_.getAnimation(animation_); | ||
47 | } | ||
48 | |||
49 | inline void setAnimation(std::string animation) | ||
50 | { | ||
51 | animation_ = std::move(animation); | ||
52 | } | ||
53 | |||
54 | private: | ||
55 | |||
56 | AnimationSet animationSet_; | ||
57 | std::string animation_; | ||
58 | size_t frame_ = 0; | ||
59 | size_t countdown_ = 0; | ||
60 | }; | ||
61 | |||
62 | #endif /* end of include guard: SPRITE_RENDERABLE_H_D3AACBBF */ | ||