summaryrefslogtreecommitdiff
path: root/src/graphics/animation.h
blob: 04bf9fff4d65824f0f8e06dd91d7b0a3570a132e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef GRAPHICS_ANIMATION_H
#define GRAPHICS_ANIMATION_H

#include <SFML/Graphics.hpp>
#include <cstddef>

namespace Graphics{

    class Animation : public sf::Drawable, sf::Transformable{
        protected:
            sf::Sprite sprite_;
            sf::Vector2i frameSize_;
            std::size_t numFrames_;
            std::size_t currentFrame_;
            std::size_t row_;
            sf::Time duration_;
            sf::Time elapsedTime_;
            bool repeat_;

        public:
            Animation();
            Animation(const sf::Texture& texture, std::size_t count,
                    sf::Time duration, bool repeat = false);
            void update(sf::Time deltaTime);
            void draw(sf::RenderTarget& target, sf::RenderStates states)
                const override;
            void reset();
            bool finished() const;
    };

}
#endif // GRAPHICS_ANIMATION_H