factored generic Animation class out of Area::TileType
[Tsunagari.git] / src / animation.h
blob60c3dbd8563abe52e667aa206267fcf2d160a228
1 /******************************
2 ** Tsunagari Tile Engine **
3 ** animation.h **
4 ** Copyright 2011 OmegaSDG **
5 ******************************/
7 #ifndef ANIMATED_H
8 #define ANIMATED_H
10 #include <vector>
12 #include <Gosu/Graphics.hpp>
14 #include "resourcer.h"
16 namespace Gosu {
17 class Image;
20 class Animation
22 public:
23 Animation();
25 void addFrame(ImageRef frame);
26 void setFrameLen(int milliseconds);
28 bool needsUpdate(int milliseconds) const;
29 void updateFrame(int milliseconds);
30 Gosu::Image* image() const;
32 private:
33 //! List of images in animation.
34 std::vector<ImageRef> frames;
36 //! Current graphic displaying on screen.
37 Gosu::Image* img;
39 //! Are we animated? Same as frames.size() > 1
40 bool animated;
42 //! Length of each frame in animation.
43 int frameLen;
45 //! Total length of one complete cycle through animation.
46 int animLen;
48 //! Index of frame currently displaying on screen.
49 int frameShowing;
52 #endif