+
+Tile *Area::TileAt(const math::Vector<int> &offset) {
+ int tileIndex(offset.Y() * width + offset.X());
+ if (tileIndex < numTiles) {
+ return tiles +tileIndex;
+ } else {
+ return 0;
+ }
+}
+
+const Tile *Area::TileAt(const math::Vector<int> &offset) const {
+ int tileIndex(offset.Y() * width + offset.X());
+ if (tileIndex < numTiles) {
+ return tiles +tileIndex;
+ } else {
+ return 0;
+ }
+}
+
+
+void Area::Render(
+ SDL_Surface *dest,
+ const graphics::Sprite *tileset,
+ const Vector<int> &inOffset,
+ unsigned int frame) const {
+ for (int i(0); i < numTiles; ++i) {
+ Vector<int> offset(
+ inOffset.X() + (i % width) * tileset->Width(),
+ inOffset.Y() + (i / width) * tileset->Height());
+ const Tile &tile(tiles[i]);
+ tileset->Draw(dest, offset,
+ tile.Offset().X(),
+ tile.Offset().Y() + (frame % tile.NumFrames()));
+ }
+}
+
+void Area::RenderDebug(SDL_Surface *dest, const graphics::Sprite *tileset, const Vector<int> &inOffset) const {
+ SDL_Rect destRect;
+ destRect.x = inOffset.X();
+ destRect.y = inOffset.Y();
+ destRect.w = Width() * tileset->Width();
+ destRect.h = Height() * tileset->Height();
+ sdl::OutlineRect(dest, &destRect, SDL_MapRGB(dest->format, 0x00, 0x00, 0xFF));
+
+ Uint32 color(SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+