From cefe66cdbb8786dc455657376e36f0ff8785d5bc Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 8 Feb 2018 12:34:42 -0500 Subject: Introduced animated sprites Also restyled a lot of the code. --- src/components/animatable.h | 75 ++++++++++++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 22 deletions(-) (limited to 'src/components/animatable.h') 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 @@ #define SPRITE_RENDERABLE_H_D3AACBBF #include "component.h" -#include "renderer.h" -#include "direction.h" +#include "animation.h" +#include class AnimatableComponent : public Component { - public: - AnimatableComponent(const char* filename, int frame_width, int frame_height, int frames_across); - - int getFrame() const; - void setFrame(int frame); - - const Texture& getTexture() const; - Rectangle getFrameRect() const; - - void setDirection(Direction dir) {}; - void setWalking(bool w) {}; - void setJumping(bool w) {}; - void setCrouching(bool w) {}; - - private: - Texture texture; - int frame_width; - int frame_height; - int frames_across; - int frame = 0; +public: + + AnimatableComponent( + AnimationSet animationSet, + std::string animation) : + animationSet_(std::move(animationSet)), + animation_(std::move(animation)) + { + } + + inline size_t getFrame() const + { + return frame_; + } + + inline void setFrame(size_t v) + { + frame_ = v; + } + + inline size_t getCountdown() const + { + return countdown_; + } + + inline void setCountdown(size_t v) + { + countdown_ = v; + } + + inline const AnimationSet& getAnimationSet() const + { + return animationSet_; + } + + inline const Animation& getAnimation() const + { + return animationSet_.getAnimation(animation_); + } + + inline void setAnimation(std::string animation) + { + animation_ = std::move(animation); + } + +private: + + AnimationSet animationSet_; + std::string animation_; + size_t frame_ = 0; + size_t countdown_ = 0; }; #endif /* end of include guard: SPRITE_RENDERABLE_H_D3AACBBF */ -- cgit 1.4.1