src/graphic/spritecache.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 cache.
00020  ******************************************************************************
00021  * 2005/09/21: Jean-Christophe Duberga (jcduberga@gmx.de)
00022  *             Initial version
00023  *****************************************************************************/
00024 
00025 #ifndef _SPRITE_CACHE_H
00026 #define _SPRITE_CACHE_H
00027 
00028 #include <vector>
00029 #include "include/base.h"
00030 #include "spriteframe.h"
00031 
00032 class Sprite;
00033 
00034 class SpriteFrameCache
00035 {
00036   bool use_rotation;
00037   std::vector<Surface> rotated_surface;
00038   std::vector<Surface> rotated_flipped_surface;
00039 
00040 public:
00041   Surface flipped_surface;
00042   Surface GetFlippedSurfaceForAngle(double angle) const;
00043   Surface GetSurfaceForAngle(double angle) const;
00044 
00045   SpriteFrameCache();
00046   void CreateRotationCache(Surface &surface, unsigned int cache_size);
00047   void CreateFlippingCache(Surface &surface);
00048 };
00049 
00050 class SpriteCache
00051 {
00052   Sprite &sprite;
00053 
00054 // TODO: Remove "public:" :-)
00055 public:
00056   bool have_rotation_cache;
00057   unsigned int rotation_cache_size;
00058   bool have_flipping_cache;
00059   bool have_lastframe_cache;
00060   Surface last_frame;
00061   std::vector<SpriteFrameCache> frames;
00062 
00063 public:
00064   explicit SpriteCache(Sprite &sprite);
00065 
00066   void EnableRotationCache(std::vector<SpriteFrame> &frames, unsigned int cache_size);
00067   void EnableFlippingCache(std::vector<SpriteFrame> &frames);
00068   void EnableLastFrameCache();
00069   void DisableLastFrameCache();
00070   void InvalidLastFrame();
00071 };
00072 
00073 #endif /* _SPRITE_CACHE_H */

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