src/graphic/spriteanimation.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *  Wormux is a convivial mass murder game.
00003  *  Copyright (C) 2001-2004 Lawrence Azzoug.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program 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
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00018  ******************************************************************************
00019  * Sprite animation control.
00020  ******************************************************************************
00021  * 2005/09/21: Jean-Christophe Duberga (jcduberga@gmx.de) 
00022  *             Initial version
00023  *****************************************************************************/
00024 
00025 #ifndef _SPRITE_ANIMATION_H
00026 #define _SPRITE_ANIMATION_H
00027 
00028 #include "include/base.h"
00029 
00030 class Sprite;
00031 
00032 class SpriteAnimation
00033 {
00034 public:
00035   typedef enum {
00036     show_first_frame,
00037     show_last_frame,
00038     show_blank
00039   } SpriteShowOnFinish;
00040 
00041 private:
00042   Sprite &sprite;
00043 
00044   // Speed
00045   unsigned int last_update;
00046   float speed_factor;
00047   int frame_delta; // Used in Update() to get next frame
00048 
00049   // State
00050   bool finished;
00051   SpriteShowOnFinish show_on_finish;
00052 
00053   // Options
00054   bool loop;
00055   bool pingpong;
00056 
00057 public:
00058   SpriteAnimation(Sprite &sprite);
00059   SpriteAnimation(const SpriteAnimation &other,Sprite &sprite);
00060 
00061   // Control animation
00062   void Start();
00063   void Update();
00064   void Finish();
00065   bool IsFinished() const;
00066 
00067   // Control speed
00068   void SetSpeedFactor(float nv_speed);
00069 
00070   // Control options
00071   void SetPlayBackward(bool enable);
00072   void SetLoopMode(bool enable);
00073   void SetPingPongMode(bool enable);
00074   void SetShowOnFinish(SpriteShowOnFinish show);
00075   SpriteShowOnFinish GetShowOnFinish() const;
00076 };
00077 
00078 #endif /* _SPRITE_ANIMATION_H */

Generated on Mon Jan 1 13:10:56 2007 for Wormux by  doxygen 1.4.7