Sprite.hh

00001 /*
00002 ** TowBowlTactics, a turn-based strategy football game.
00003 **
00004 ** Copyright (C) 2006-2010 The TBT Team.
00005 **
00006 ** This program is free software; you can redistribute it and/or
00007 ** modify it under the terms of the GNU General Public License
00008 ** as published by the Free Software Foundation; either version 2
00009 ** of the License, or (at your option) any later version.
00010 **
00011 ** The complete GNU General Public Licence Notice can be found as the
00012 ** `NOTICE' file in the root directory.
00013 **
00014 ** The TBT Team consists of people listed in the `AUTHORS' file.
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   // Animation
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   // Moving
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 /* !SPRITE_HH_ */
Generated on Mon Apr 5 21:17:13 2010 for Stechec/TBT by  doxygen 1.6.3