summaryrefslogtreecommitdiff
path: root/src/graphics/animation.h
blob: 9f5dfa51cafe3bd30985c25864e38bd44947a656 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef GRAPHICS_ANIMATION_H
#define GRAPHICS_ANIMATION_H

#include <SFML/Graphics.hpp>

namespace Graphics{

    class Animation{
        protected:
            int i_;
            int count_;
            int row_;
            int lastTime_;
            int switchTime_;
            unsigned int w_, h_;
            sf::IntRect rect_;
            sf::Texture texture_;
            bool ticked(int deltaTime);
        public:
            Animation();
            ~Animation();
            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 sf::Texture& texture, int count, int
                    switchTime, int height, int width, int row);
            bool finished();
            sf::IntRect& next(int deltaTime);
    };

    class BouncingAnimation : Animation{
        private:
            bool up_;
        public:
            BouncingAnimation();
            BouncingAnimation(const sf::Texture& texture, int count, int
                    switchTime, int height, int width, int row);
            ~BouncingAnimation();
            sf::IntRect& next(int deltaTime);
    };
}
#endif // GRAPHICS_ANIMATION_H