00001 /* This file is part of Annchienta. 00002 * Copyright 2008 (C) Jasper Van der Jeugt 00003 * 00004 * Annchienta is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * Annchienta 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. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with Annchienta. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef ANNCHIENTA_MAP_H 00019 #define ANNCHIENTA_MAP_H 00020 00021 #include <vector> 00022 #include "Engine.h" 00023 #include "Point.h" 00024 00025 namespace Annchienta 00026 { 00027 00028 class TileSet; 00029 class Layer; 00030 class StaticObject; 00031 class Person; 00032 00038 class Map 00039 { 00040 00041 private: 00042 00043 /* We need to draw some shit. */ 00044 VideoManager *videoManager; 00045 00046 /* TileSet used in this map. */ 00047 TileSet *tileSet; 00048 00049 int width, height; 00050 00051 /* All layers in the level. */ 00052 std::vector<Layer*> layers; 00053 Layer **sortedLayers; 00054 int currentLayer; 00055 00056 char fileName[DEFAULT_STRING_SIZE]; 00057 00058 char *onPreRenderScript, *onPreRenderCode; 00059 char *onPostRenderScript, *onPostRenderCode; 00060 00061 public: 00062 00067 Map( const char *fileName, bool scripts=true ); 00068 00074 Map( int w, int h, const char *tileset ); 00075 ~Map(); 00076 00079 Layer *getCurrentLayer() const; 00080 00084 Layer *getLayer( int index ) const; 00085 00088 int getCurrentLayerIndex() const; 00089 00093 void setCurrentLayer( int index ); 00094 00097 int getNumberOfLayers() const; 00098 00101 const char *getFileName() const; 00102 00105 int getWidth() const; 00106 00109 int getHeight() const; 00110 00114 void addNewLayer( int z=0 ); 00115 00118 TileSet *getTileSet() const; 00119 00126 StaticObject *getObject( const char *name ); 00127 00132 Person *getPerson( const char *name ); 00133 00139 void addObject( StaticObject *so, Point position ); 00140 00145 void removeObject( StaticObject *so ); 00146 00150 void update(); 00151 00155 void draw( bool scripts=true ) const; 00156 00159 void depthSort(); 00160 00163 void sortLayers(); 00164 00168 void onPreRender() const; 00169 00173 void onPostRender() const; 00174 00175 }; 00176 }; 00177 00178 #endif 00179