]> git.localhorst.tv Git - l2e.git/blobdiff - src/map/Area.cpp
check blocking flags of tiles in map state
[l2e.git] / src / map / Area.cpp
index a1ae6804c774b9627fd7b98aeae9b6963fd3b717..292b8952f21ecca579aa4af9a18112e968e5810a 100644 (file)
@@ -10,6 +10,8 @@
 #include "Tile.h"
 #include "../graphics/Sprite.h"
 
+#include <stdexcept>
+
 using geometry::Vector;
 
 namespace map {
@@ -21,6 +23,17 @@ Area::Area()
 
 }
 
+
+const Tile &Area::TileAt(const geometry::Vector<int> &offset) const {
+       int tileIndex(offset.Y() * width + offset.X());
+       if (tileIndex < numTiles) {
+               return tiles[tileIndex];
+       } else {
+               throw std::out_of_range("tile index out of range");
+       }
+}
+
+
 void Area::Render(SDL_Surface *dest, const graphics::Sprite *tileset, const Vector<int> &inOffset) const {
        for (int i(0); i < numTiles; ++i) {
                Vector<int> offset(