summary refs log tree commit diff stats
path: root/src/components/animatable.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/animatable.h')
-rw-r--r--src/components/animatable.h75
1 files changed, 53 insertions, 22 deletions
diff --git a/src/components/animatable.h b/src/components/animatable.h index cf6ee54..ed0133e 100644 --- a/src/components/animatable.h +++ b/src/components/animatable.h
@@ -2,30 +2,61 @@
2#define SPRITE_RENDERABLE_H_D3AACBBF 2#define SPRITE_RENDERABLE_H_D3AACBBF
3 3
4#include "component.h" 4#include "component.h"
5#include "renderer.h" 5#include "animation.h"
6#include "direction.h" 6#include <string>
7 7
8class AnimatableComponent : public Component { 8class AnimatableComponent : public Component {
9 public: 9public:
10 AnimatableComponent(const char* filename, int frame_width, int frame_height, int frames_across); 10
11 11 AnimatableComponent(
12 int getFrame() const; 12 AnimationSet animationSet,
13 void setFrame(int frame); 13 std::string animation) :
14 14 animationSet_(std::move(animationSet)),
15 const Texture& getTexture() const; 15 animation_(std::move(animation))
16 Rectangle getFrameRect() const; 16 {
17 17 }
18 void setDirection(Direction dir) {}; 18
19 void setWalking(bool w) {}; 19 inline size_t getFrame() const
20 void setJumping(bool w) {}; 20 {
21 void setCrouching(bool w) {}; 21 return frame_;
22 22 }
23 private: 23
24 Texture texture; 24 inline void setFrame(size_t v)
25 int frame_width; 25 {
26 int frame_height; 26 frame_ = v;
27 int frames_across; 27 }
28 int frame = 0; 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
54private:
55
56 AnimationSet animationSet_;
57 std::string animation_;
58 size_t frame_ = 0;
59 size_t countdown_ = 0;
29}; 60};
30 61
31#endif /* end of include guard: SPRITE_RENDERABLE_H_D3AACBBF */ 62#endif /* end of include guard: SPRITE_RENDERABLE_H_D3AACBBF */