src/map/map.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  * Monde ou plateau de jeu.
00020  *****************************************************************************/
00021 
00022 #ifndef MAP_H
00023 #define MAP_H
00024 
00025 #include "ground.h"
00026 #include "sky.h"
00027 #include "water.h"
00028 #include "../graphic/surface.h"
00029 #include "../graphic/sprite.h"
00030 #include "../graphic/text.h"
00031 #include "../include/base.h"
00032 #include "../object/physical_obj.h"
00033 
00034 extern const uint MAX_WIND_OBJECTS;
00035 
00036 class Map{
00037  private:
00038   Text * author_info1;
00039   Text * author_info2;
00040 
00041 public:
00042   Map();
00043   ~Map();
00044    
00045   Ground ground;
00046   Sky sky;
00047   double dst_min_entre_vers;
00048   Water water;
00049 
00050   std::list<Rectanglei> *to_redraw;
00051   std::list<Rectanglei> *to_redraw_now;
00052   std::list<Rectanglei> *to_redraw_particles;
00053   std::list<Rectanglei> *to_redraw_particles_now;
00054 
00055 public:
00056   void Reset();
00057   void Refresh();
00058   void FreeMem();
00059   void Draw();
00060   void DrawWater();
00061   void DrawSky();
00062   void DrawAuthorName();
00063 
00064   // To manage the cache mechanism
00065   void ToRedrawOnMap(Rectanglei r);
00066   void ToRedrawOnScreen(Rectanglei r);
00067 
00068   // Est-on dans le monde ou dans le vide ?
00069   bool EstDansVide (int x, int y);
00070   bool LigneH_EstDansVide (int left, int y,  int right);
00071   bool LigneV_EstDansVide (int x,  int top, int bottom);
00072   bool RectEstDansVide (const Rectanglei &rect);
00073   bool ParanoiacRectIsInVacuum (const Rectanglei &rect);
00074 
00075   // La ligne du haut/bas d'un objet physique est dans le vide ?
00076   // Le test se fait sur le rectangle de test d�al�de dx et dy.
00077   bool EstDansVide_haut (const PhysicalObj &obj, int dx, int dy);
00078   bool EstDansVide_bas (const PhysicalObj &obj, int dx, int dy);
00079   bool IsInVacuum_left (const PhysicalObj &obj, int dx, int dy);
00080   bool IsInVacuum_right (const PhysicalObj &obj, int dx, int dy);
00081 
00082   // Est en dehors du monde ?
00083   bool EstHorsMondeX (int x) const;
00084   bool EstHorsMondeY (int x) const;
00085   bool EstHorsMondeXlarg (int x, uint larg) const;
00086   bool EstHorsMondeYhaut (int x, uint haut) const;
00087   bool EstHorsMondeXY (int x, int y) const;
00088   bool EstHorsMonde (const Point2i &pos) const;
00089 
00090   // C'est un terrain ouvert ?
00091   bool EstOuvert() const { return ground.EstOuvert(); }
00092 
00093   // Dig the map using a picture
00094   void Dig(const Point2i position, const Surface& alpha_sur);
00095   // Dig a circle hole in the map
00096   void Dig(const Point2i center, const uint radius);
00097 
00098   // Insert a sprite into the ground
00099   void PutSprite(const Point2i pos, Sprite* spr);
00100   // Merge a sprite into the ground
00101   void MergeSprite(const Point2i pos, Sprite* spr);
00102 
00103   // Lit la taille du monde
00104   int GetWidth() const { return ground.GetSizeX(); }
00105   int GetHeight() const { return ground.GetSizeY(); }
00106   Point2i GetSize() const{ return ground.GetSize(); }
00107  private:
00108   void SwitchDrawingCache();
00109   void SwitchDrawingCacheParticles();
00110   void OptimizeCache(std::list<Rectanglei>& rectangleCache);
00111 };
00112 
00113 extern Map world;
00114 #endif

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