summaryrefslogtreecommitdiff
path: root/src/graphics/animation.h
blob: 87b44279f3b6e1c8e2476e5e05ddddf4cb70ee74 (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
#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