Sprite.hh
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef SPRITE_HH_
00018 # define SPRITE_HH_
00019
00020 # include "Surface.hh"
00021
00043 class Sprite : public Surface
00044 {
00045 public:
00047 Sprite();
00052 Sprite(SDL_Surface* surf, double zoom = 1., double angle = 0.);
00057 Sprite(const std::string filename, double zoom = 1., double angle = 0.);
00058 virtual ~Sprite();
00059
00066 void splitNbFrame(int nb_frame_width, int nb_frame_height);
00073 void splitSizeFrame(int size_frame_width, int size_frame_height);
00074
00079 void move(const Point& to, double velocity);
00085 void move(int to_x, int to_y, double velocity);
00087 void stopMove();
00088 bool isMoving();
00089
00095 void anim(int delay, bool loop_forever = true);
00097 void stopAnim();
00098 bool isAnimated();
00099
00105 void setFrame(int frame);
00110 void setTransparency(int level);
00111
00112 virtual void setZoom(double zoom);
00113
00114 virtual void update();
00115
00116 virtual void blit(Surface& to);
00117 virtual void blit(Surface& to, const Rect& to_rect, const Rect& from_rect);
00118
00119 private:
00120
00121 int nb_anim_width_;
00122 int nb_anim_height_;
00123 int current_anim_;
00124 unsigned last_anim_updated_;
00125 int anim_delay_;
00126 bool anim_loop_;
00127 bool is_animated_;
00128
00129
00130 Point move_from_;
00131 Point move_to_;
00132 DPoint current_pos_;
00133 unsigned last_updated_;
00134 bool is_moving_;
00135 double velocity_;
00136 };
00137
00138 #endif