Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
csanim2d.h
00001 /* 00002 Copyright (C) 2000 by Jorrit Tyberghein 00003 Copyright (C) 2001 by W.C.A. Wijngaards 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CS_CSANIM2D_H__ 00021 #define __CS_CSANIM2D_H__ 00022 00023 #include "csextern.h" 00024 00025 #include "cstool/cspixmap.h" 00026 #include "csutil/array.h" 00027 #include "csutil/parray.h" 00028 00029 struct iGraphics3D; 00030 struct iTextureHandle; 00031 00032 class csPixmap; 00033 class csAnimatedPixmap; 00034 00036 class CS_CRYSTALSPACE_EXPORT csAnimationTemplate 00037 { 00038 private: 00040 csPDelArray<csPixmap> Frames; 00045 csArray<csTicks> FinishTimes; 00046 00047 public: 00049 csAnimationTemplate(); 00051 ~csAnimationTemplate(); 00052 00054 inline size_t GetFrameCount() const 00055 {return Frames.Length();} 00057 inline csTicks GetLength() const 00058 { 00059 if (GetFrameCount() == 0) 00060 return 0; 00061 else 00062 return (csTicks)(FinishTimes.Get (GetFrameCount()-1)); 00063 } 00065 inline void AddFrame(csTicks Delay, csPixmap *s) 00066 {FinishTimes.Push(GetLength() + Delay); Frames.Push (s);} 00068 inline void AddFrame(csTicks Delay, iTextureHandle *Tex) 00069 {AddFrame(Delay, new csSimplePixmap(Tex));} 00071 inline void AddFrame(csTicks Delay, iTextureHandle *Tex, int x, int y, 00072 int w, int h) 00073 {AddFrame(Delay, new csSimplePixmap(Tex, x, y, w, h));} 00074 00076 inline csPixmap *GetFrame(size_t n) const 00077 {return Frames.Get(n);} 00079 csPixmap *GetFrameByTime(csTicks Time); 00080 00082 csAnimatedPixmap *CreateInstance(); 00083 }; 00084 00085 00087 class CS_CRYSTALSPACE_EXPORT csAnimatedPixmap : public csPixmap 00088 { 00089 public: 00091 csAnimatedPixmap(csAnimationTemplate *tpl); 00093 virtual ~csAnimatedPixmap(); 00094 00095 // Implementation of csPixmap. 00096 virtual int Width(); 00097 virtual int Height(); 00098 virtual iTextureHandle *GetTextureHandle(); 00099 virtual void DrawScaled (iGraphics3D* g3d, int sx, int sy, int sw, int sh, 00100 uint8 Alpha = 0); 00101 virtual void DrawTiled (iGraphics3D* g3d, int sx, int sy, int sw, int sh, 00102 int orgx, int orgy, uint8 Alpha = 0); 00103 virtual void Advance(csTicks ElapsedTime); 00104 00105 private: 00106 csAnimationTemplate *Template; 00107 csTicks CurrentTime; 00108 csPixmap *CurrentFrame; 00109 }; 00110 00111 #endif // __CS_CSANIM2D_H__
Generated for Crystal Space by doxygen 1.4.4