00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CS_ANIM2D_H__
00021 #define __CS_ANIM2D_H__
00022
00023 #include "csutil/csvector.h"
00024 #include "cstool/cspixmap.h"
00025
00026 struct iGraphics3D;
00027 class csPixmap;
00028 class csAnimatedPixmap;
00029
00031 class csAnimationTemplate {
00032 private:
00034 csVector Frames;
00039 csVector FinishTimes;
00040
00041 public:
00043 csAnimationTemplate();
00045 ~csAnimationTemplate();
00046
00048 inline int GetFrameCount() const
00049 {return Frames.Length();}
00051 inline csTicks GetLength() const
00052 {return (GetFrameCount()==0)?0:(csTicks)FinishTimes.Get(GetFrameCount()-1);}
00054 inline void AddFrame(csTicks Delay, csPixmap *s)
00055 {FinishTimes.Push((csSome)(GetLength() + Delay)); Frames.Push(s);}
00057 inline void AddFrame(csTicks Delay, iTextureHandle *Tex)
00058 {AddFrame(Delay, new csSimplePixmap(Tex));}
00060 inline void AddFrame(csTicks Delay, iTextureHandle *Tex, int x, int y, int w, int h)
00061 {AddFrame(Delay, new csSimplePixmap(Tex, x, y, w, h));}
00062
00064 inline csPixmap *GetFrame(int n) const
00065 {return (csPixmap*)(Frames.Get(n));}
00067 csPixmap *GetFrameByTime(csTicks Time);
00068
00070 csAnimatedPixmap *CreateInstance();
00071 };
00072
00073
00075 class csAnimatedPixmap : public csPixmap {
00076 public:
00078 csAnimatedPixmap(csAnimationTemplate *tpl);
00080 virtual ~csAnimatedPixmap();
00081
00082
00083 virtual int Width();
00084 virtual int Height();
00085 virtual iTextureHandle *GetTextureHandle();
00086 virtual void DrawScaled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
00087 uint8 Alpha = 0);
00088 virtual void DrawTiled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
00089 int orgx, int orgy, uint8 Alpha = 0);
00090 virtual void Advance(csTicks ElapsedTime);
00091
00092 private:
00093 csAnimationTemplate *Template;
00094 csTicks CurrentTime;
00095 csPixmap *CurrentFrame;
00096 };
00097
00098 #endif // __CS_ANIM2D__