src/map/tile.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 
00020 #ifndef _TILE_H
00021 #define _TILE_H
00022 
00023 #include <vector>
00024 #include "tileitem.h"
00025 #include "../graphic/surface.h"
00026 #include "../graphic/sprite.h"
00027 #include "../tool/rectangle.h"
00028 
00029 const uint EXPLOSION_BORDER_SIZE = 10;
00030 
00031 class TileItem;
00032 
00033 class Tile : public Rectanglei{
00034 public:
00035   Tile ();
00036   ~Tile ();
00037 
00038   // Dig a hole
00039   void Dig(const Point2i &position, const Surface& provider);
00040   // Dig a circle hole
00041   void Dig(const Point2i &center, const uint radius);
00042 
00043   // Insert a sprite into the ground
00044   void PutSprite(const Point2i pos, Sprite* spr);
00045   // Merge a sprite into map (using alpha information)
00046   void MergeSprite(const Point2i &position, Surface & provider);
00047 
00048   // Load an image
00049   void LoadImage (Surface& ground_surface);
00050 
00051   // Get alpha value of a pixel
00052   unsigned char GetAlpha(const Point2i &pos) const;
00053 
00054   // Draw it (on the entire visible part) 
00055   void DrawTile();
00056 
00057   // Draw a part that is inside the given clipping rectangle
00058   // Clipping rectangle is in World corrdinate not screen coordinates
00059   // usefull to redraw only a part that is under a sprite that has moved,... 
00060   void DrawTile_Clipped(Rectanglei clip_rectangle) const;
00061 
00062   // Return a surface of the ground inside the rect
00063   Surface GetPart(Rectanglei& rec);
00064 
00065   // Check if a title is empty, so we can delete it
00066   void CheckEmptyTiles();
00067 protected:
00068   void InitTile(const Point2i &pSize);
00069 
00070   void FreeMem();
00071   Point2i Clamp(const Point2i &v) const;
00072 
00073   // Dimension du terrain
00074   Point2i nbCells;
00075   unsigned int nbr_cell;
00076 
00077   // Canvas donnant acc� aux cellules
00078   std::vector<TileItem *> item;
00079 };
00080 
00081 #endif // _TILE_H

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