Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

sprite.h

Go to the documentation of this file.
00001 #ifndef __SPRITE_H
00002 #define __SPRITE_H
00003 
00004 #include <vector>
00005 #include <string>
00006 #include "graphics.h"
00007 #include "util.h"
00008 #include "spritecache.h"
00009 
00014 
00015 class Sprite {
00016 public:
00017 
00019         
00021         Sprite(string sprname = "");
00022         
00024         Sprite(string filename, string sprname = "");
00025         
00027         Sprite(vector<string> &filenames, string sprname = "");
00028         
00030         Sprite(Surface *frame, string sprname = "");
00031         
00033         Sprite(vector<Surface *> &sframes, string sprname = "");
00034         
00036         Sprite(const Sprite &);
00037         
00039         virtual ~Sprite();
00040         
00041         
00043         virtual void animate();
00044         
00046         virtual Rect draw(Graphics &);
00047         
00049         virtual Rect draw(Surface *);
00050 
00051         
00054         void ReverseAnimation(bool);
00055         
00057         void EnableAnimation(bool);
00058         
00060         void ToggleAnimation();
00061         
00063         void SetAnimateTime(int ms);    
00064 
00066         void SetAnimationStartFrame(int);
00067         
00069         void SetAnimationEndFrame(int);
00070 
00072         void Show(bool);
00073                 
00075         void SetFrame(int);
00076         
00078         int  GetFrame() const;
00079         
00081         int  CountFrames();
00082 
00084         virtual int  SetPosition(double x = 0.0, double y = 0.0);
00085                 
00087         string GetName() const;
00088         
00090         void SetName(string);
00091         
00094         Sprite& operator++();
00095         Sprite  operator++(int);
00096         
00098         Sprite& operator--();
00099         Sprite  operator--(int);
00100         
00102         Sprite& operator=(int);
00103 
00104         int GetWidth() const { return w; }
00105         int GetHeight() const { return h; }
00106         double GetX() const { return x; }
00107         double GetY() const { return y; }
00108         
00111         int LoadFrames(vector<Surface *>& sframes);
00112         int LoadFrames(vector<string>& filenames);
00113         int LoadFrame(Surface *frame);
00114         int LoadFrame(string filename);
00115         
00117         int AddFrame(Surface *frame);
00118         int AddFrame(string filename);
00119         
00121         int AppendFrame(Surface *frame);
00122         
00124         bool RemoveFrame(int);
00125         
00127         bool EmptyFrames();
00128 
00129         static SpriteCache cache;       
00130 protected:
00132         void init();
00133         void close();
00134         
00135 private:
00136         vector<Surface *> frames;
00137         bool free_frames_on_exit;
00138 
00139         unsigned int current_frame;
00140         double x, y;
00141         int w, h;
00142         
00144         string name;            
00145         
00146         bool visible;
00147         
00148         struct _animinfo {
00149                 int delay;      
00150                 nnctime lastanimtime;
00151                 bool reverse;   
00152                 
00154                 int start_frame;
00155                 int end_frame;
00156         
00157                 bool enabled;
00158         } animinfo;
00159 };
00160 
00161 
00162 #endif

Generated on Sun Dec 8 12:02:20 2002 for nnc by doxygen1.3-rc1