From 2e7d74e2622e13a6986cffd2c8d4423b840c5e59 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Sat, 12 Nov 2022 17:27:53 +0100 Subject: First mini-commit that works with a not-included spritesheet --- src/graphics/animation.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/graphics/animation.h (limited to 'src/graphics/animation.h') 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 + +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 -- cgit v1.2.3