diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2022-11-12 17:27:53 +0100 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2022-11-12 17:47:26 +0100 |
commit | 2e7d74e2622e13a6986cffd2c8d4423b840c5e59 (patch) | |
tree | 03f20878eadc5f09da020a386397500a60abc07f /src/graphics/animation.h |
First mini-commit that works with a not-included spritesheet
Diffstat (limited to 'src/graphics/animation.h')
-rw-r--r-- | src/graphics/animation.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/graphics/animation.h b/src/graphics/animation.h new file mode 100644 index 0000000..87b4427 --- /dev/null +++ b/src/graphics/animation.h @@ -0,0 +1,44 @@ +#ifndef GRAPHICS_ANIMATION_H +#define GRAPHICS_ANIMATION_H + +#include <SFML/Graphics.hpp> + +namespace Graphics{ + + class Animation{ + protected: + int i_; + int count_; + int lastTime_; + int switchTime_; + unsigned int w_, h_; + sf::IntRect rect_; + sf::Texture texture_; + sf::Sprite sprite_; + bool ticked(int deltaTime); + public: + Animation(); + ~Animation(); + Animation(const char* filename, int count, int switchTime); + sf::Sprite& next(int deltaTime); + }; + + class OneShotAnimation : Animation { + public: + OneShotAnimation(); + OneShotAnimation(const char* filename, int count, int switchTime); + bool finished(); + sf::Sprite& next(int deltaTime); + }; + + class BouncingAnimation : Animation{ + private: + bool up_; + public: + BouncingAnimation(); + BouncingAnimation(const char* filename, int count, int switchTime); + ~BouncingAnimation(); + sf::Sprite& next(int deltaTime); + }; +} +#endif // GRAPHICS_ANIMATION_H |