]> git.localhorst.tv Git - l2e.git/blob - src/graphics/ComplexAnimation.h
added setters for animations
[l2e.git] / src / graphics / ComplexAnimation.h
1 /*
2  * ComplexAnimation.h
3  *
4  *  Created on: Aug 12, 2012
5  *      Author: holy
6  */
7
8 #ifndef GRAPHICS_COMPLEXANIMATION_H_
9 #define GRAPHICS_COMPLEXANIMATION_H_
10
11 #include "Animation.h"
12
13 #include <vector>
14
15 namespace graphics {
16
17 class ComplexAnimation
18 : public Animation {
19
20 public:
21         ComplexAnimation() { }
22         ComplexAnimation(const Sprite *sprite, int frameTime, bool repeat = false)
23         : Animation(sprite, frameTime, repeat) { }
24
25 public:
26         void AddFrame(int col, int row, const geometry::Vector<int> &disposition = geometry::Vector<int>()) {
27                 frames.push_back(FrameProp(col, row, disposition));
28         }
29         void AddFrames(int col, int row, const geometry::Vector<int> &disposition, int amount) {
30                 for (int i(0); i < amount; ++i) {
31                         AddFrame(col, row, disposition);
32                 }
33         }
34
35 public:
36         struct FrameProp {
37                 FrameProp() : col(0), row(0) { }
38                 FrameProp(int col, int row, const geometry::Vector<int> &disposition)
39                 : col(col), row(row), disposition(disposition) {}
40                 int col;
41                 int row;
42                 geometry::Vector<int> disposition;
43         };
44         void AddFrame(const FrameProp &f) { frames.push_back(f); }
45
46 protected:
47         virtual int NumFrames() const { return frames.size(); };
48         virtual int Col(int frame) const { return frames[frame].col; }
49         virtual int Row(int frame) const { return frames[frame].row; }
50         virtual geometry::Vector<int> Offset(int frame) const { return frames[frame].disposition; }
51
52 private:
53         std::vector<FrameProp> frames;
54
55 };
56
57 }
58
59 #endif /* GRAPHICS_COMPLEXANIMATION_H_ */