4 * Created on: Sep 26, 2012
11 #include "../graphics/Sprite.h"
15 using geometry::Vector;
27 const Tile &Area::TileAt(const geometry::Vector<int> &offset) const {
28 int tileIndex(offset.Y() * width + offset.X());
29 if (tileIndex < numTiles) {
30 return tiles[tileIndex];
32 throw std::out_of_range("tile index out of range");
37 void Area::Render(SDL_Surface *dest, const graphics::Sprite *tileset, const Vector<int> &inOffset) const {
38 for (int i(0); i < numTiles; ++i) {
40 inOffset.X() + (i % width) * tileset->Width(),
41 inOffset.Y() + (i / width) * tileset->Height());
42 const Tile &tile(tiles[i]);
43 tileset->Draw(dest, offset, tile.Offset().X(), tile.Offset().Y());