X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmap%2FArea.cpp;h=292b8952f21ecca579aa4af9a18112e968e5810a;hb=d969efe468d2d9775ab2c5388be1cde8efa0b9ad;hp=a1ae6804c774b9627fd7b98aeae9b6963fd3b717;hpb=59c4aea0762cbc5f1bf74c5b1b35629408fb92af;p=l2e.git diff --git a/src/map/Area.cpp b/src/map/Area.cpp index a1ae680..292b895 100644 --- a/src/map/Area.cpp +++ b/src/map/Area.cpp @@ -10,6 +10,8 @@ #include "Tile.h" #include "../graphics/Sprite.h" +#include + using geometry::Vector; namespace map { @@ -21,6 +23,17 @@ Area::Area() } + +const Tile &Area::TileAt(const geometry::Vector &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 &inOffset) const { for (int i(0); i < numTiles; ++i) { Vector offset(