diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2022-11-12 23:01:24 +0100 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2022-11-12 23:01:50 +0100 |
commit | c8663de4fbdb30534723df6c8d1331535dcdadc2 (patch) | |
tree | d2c1b9aed268c74f4ddc83f540a182950262f9d6 /src/graphics/animation.h | |
parent | 2e7d74e2622e13a6986cffd2c8d4423b840c5e59 (diff) |
Reorganize to make animations easily changeable:
Animations now return rectangles so the texture is independent from
them and they don't store the sprite either.
Many Animations may have the same texture.
Changing from one Animation to another is just changing a reference.
Diffstat (limited to 'src/graphics/animation.h')
-rw-r--r-- | src/graphics/animation.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/graphics/animation.h b/src/graphics/animation.h index 87b4427..9f5dfa5 100644 --- a/src/graphics/animation.h +++ b/src/graphics/animation.h @@ -9,26 +9,29 @@ namespace Graphics{ protected: int i_; int count_; + int row_; 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); + Animation(const sf::Texture& texture, int count, int switchTime, + int height, int width, int row); + sf::IntRect& next(int deltaTime); + void reset(); }; class OneShotAnimation : Animation { public: OneShotAnimation(); - OneShotAnimation(const char* filename, int count, int switchTime); + OneShotAnimation(const sf::Texture& texture, int count, int + switchTime, int height, int width, int row); bool finished(); - sf::Sprite& next(int deltaTime); + sf::IntRect& next(int deltaTime); }; class BouncingAnimation : Animation{ @@ -36,9 +39,10 @@ namespace Graphics{ bool up_; public: BouncingAnimation(); - BouncingAnimation(const char* filename, int count, int switchTime); + BouncingAnimation(const sf::Texture& texture, int count, int + switchTime, int height, int width, int row); ~BouncingAnimation(); - sf::Sprite& next(int deltaTime); + sf::IntRect& next(int deltaTime); }; } #endif // GRAPHICS_ANIMATION_H |