Hosting courtesy of Sourceforge

SourceForge Logo
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

GameMap.h

Go to the documentation of this file.
00001 //
00002 //      Copyright (C) 2002 Robert Renaud
00003 //
00004 //      This program is free software; you can redistribute it and/or
00005 //      modify it under the terms of the GNU General Public License
00006 //      as published by the Free Software Foundation; either version 2
00007 //      of the License, or (at your option) any later version.
00008 //
00009 //      This program is distributed in the hope that it will be useful,
00010 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 //
00013 //      See the 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 
00021 #ifndef GAME_MAP_H_
00022 #define GAME_MAP_H_
00023 
00024 #include "../Config.h"
00025 
00026 #include <vector>
00027 #include <string>
00028 
00029 #include "SDL.h"
00030 
00031 #include "GameDebug.h"
00032 #include "Bomb.h"
00033 #include "Flame.h"
00034 #include "MapLocation.h"
00035 #include "Moveable.h"
00036 #include "Player.h"
00037 #include "Powerup.h"
00038 #include "Tile.h"
00039 
00040 #include "../Parse/ListParser.h"
00041 #include "../Parse/Parse.h"
00042 #include "../Util/Matrix.h"
00043 #include "../Util/GeneralException.h"
00044 #include "../Util/STL_Helper.h"
00045 
00046 using std::vector; using std::string;
00051 namespace Game {
00052 
00053         namespace Constants {
00054                 const size_t MAP_NUM_ROWS=16;
00055                 const size_t MAP_NUM_COLS=16;
00056 
00077                 const bool ALLOW_BOMB_STACKING=false;
00078     };
00082         class GameMap {
00083         public:
00084                 GameMap();
00085                 ~GameMap();
00086 
00090                 bool runGame(SDL_Surface* screen);
00091                 void readMap(std::istream& input);
00092 
00099                 bool tileIsPassable(int x, int y) const;                
00100 
00102                 void explodeTile(int x, int y);
00103 
00108                 void addPlayer(const std::string& blpFile, const std::string& cfgFile);
00109 
00110         private:                
00111 
00112                 enum FlameStatus {
00113                         FLAME_STOP,
00114                         FLAME_KEEP_GOING
00115                 };
00116 
00117                 struct BombPlayerPair {
00118                         BombPlayerPair(AbstractPlayer* owner);
00119                         ~BombPlayerPair();
00120                         AbstractPlayer* owner;
00121                         Bomb* bomb;
00122                         MapLocation bombLoc;
00123                         bool markedForDeletion;
00124                         bool operator < (const BombPlayerPair& other) const;
00125                         bool operator == (const BombPlayerPair& other) const;
00126                 };              
00127 
00128                 class BombPairAtPred {                  
00129                         GameMap* gameMap;
00130                         int x, y;
00131                 public:
00132                         BombPairAtPred(GameMap* map, int mapX, int mapY);
00133                         bool operator()(const BombPlayerPair* b);
00134                 };
00135                 
00136                 friend class BombPairAtPred;
00137 
00138                 struct MapTile {
00139                         MapTile();
00140                         ~MapTile();
00141                         BombPlayerPair* bombOwnerPair;
00142                         Powerup* powerup;
00143                         AbstractTile* tile;                     
00144                         Flame flame;
00145                 };
00146 
00147                 void putBomb(AbstractPlayer* player);
00148                 void blowUpBomb(BombPlayerPair* b);             
00149 
00150                 void occupyTile(int x, int y);          
00151                 void deOccupyTile(int x, int y);
00152                 bool isValidLocation(int x, int y) const;
00153                 void removePowerupAt(int x, int y);
00154 
00155                 bool playerHitByBomb(AbstractPlayer* p);
00156                 
00157                 bool moveObject(MoveableItem& m, Direction d, int speed, bool allowDirChange=true, int st = Constants::SLACK_TOLERANCE);
00158                 bool moveHoriz(MoveableItem& m, int amount, int questionableHorizTileLoc, int slack, int st = Constants::SLACK_TOLERANCE);
00159                 bool moveVert(MoveableItem& m, int amount, int questionableVertTileLoc, int slack, int st = Constants::SLACK_TOLERANCE);
00160 
00161                 MapLocation getEmptyStartSpot();
00162                 
00163                 void deleteMarkedBombs();
00164 
00165                 FlameStatus handleBombChain(int x, int y, FlameType dir);
00166 
00167                 Util::Matrix<MapTile*> tileMatrix;
00168                 std::list<AbstractPlayer*> playerList;
00169                 std::list<MapLocation*> openStartLocations;
00170                 std::set<BombPlayerPair*> bombPlayerSet;
00171                 std::list<MapLocation*> tilesToExplode;
00172         }; // class GameMap
00173 
00174 }; // namespace Game
00175 
00176 #endif // ifndef GAME_MAP_H
00177 

Generated on Tue May 21 07:26:51 2002 for BomberLAN by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001