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_LAYER_H 00019 #define ANNCHIENTA_LAYER_H 00020 00021 #include <vector> 00022 #include "Point.h" 00023 00024 namespace Annchienta 00025 { 00026 class Tile; 00027 class Entity; 00028 class TileSet; 00029 class StaticObject; 00030 class Area; 00031 00032 class Layer 00033 { 00034 00035 private: 00036 /* Number of tiles. 00037 */ 00038 int width, height; 00039 int opacity; 00040 00041 /* Z offset 00042 */ 00043 int z; 00044 00045 Tile **tiles; 00046 00047 /* This is another list that holds ALL entities in the 00048 * layer. This even includes tiles. 00049 */ 00050 std::vector<Entity*> entities; 00051 std::vector<StaticObject*> staticObjects; 00052 std::vector<Area*> areas; 00053 00054 TileSet *tileSet; 00055 00056 public: 00057 00058 /* Do not use this constructor. It's a fake one to keep 00059 * SWIG satisfied. 00060 */ 00061 Layer(); 00062 00063 #ifndef SWIG 00064 /* Layer::setTiles MUST, I repeat, MUST be called right 00065 * after this. 00066 */ 00067 Layer( TileSet *tileSet, int width, int height, int opacity, int z ); 00068 ~Layer(); 00069 00075 void setTiles( Tile **tiles=0 ); 00076 00079 bool hasTiles() const; 00080 #endif 00081 00082 00088 void setOpacity( int opacity=255 ); 00089 00092 int getOpacity() const; 00093 00097 void setZ( int z ); 00098 00101 int getZ() const; 00102 00105 void update(); 00106 00109 void draw() const; 00110 00115 void depthSort(); 00116 00121 void addObject( StaticObject *staticObject, Point position ); 00122 00126 void addArea( Area *area ); 00127 00131 void makeEmpty(); 00132 00137 void setTileSet( TileSet *tileSet ); 00138 00142 TileSet *getTileSet() const; 00143 00146 int getWidth() const; 00147 00150 int getHeight() const; 00151 00157 Tile *getTile( int x, int y ); 00158 00163 StaticObject *getObject( int num ) const; 00164 00169 StaticObject *getObject( const char *name ) const; 00170 00173 int getNumberOfObjects() const; 00174 00178 void removeObject( StaticObject *staticObject ); 00179 00184 Area *getArea( int num ) const; 00185 00188 int getNumberOfAreas() const; 00189 }; 00190 }; 00191 00192 #endif