X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmap%2FMap.cpp;h=fc664c1d7d4e26c0060176bf0283002abfbbe5a6;hb=9f352d64f920f46a2d5b4fe67408154629933293;hp=c7d75f18af409dc3774fadfa8098d6a1b3bf8851;hpb=07cdc452aeaad73ca9f8f9a3cf9868d2b6c9d5b3;p=l2e.git diff --git a/src/map/Map.cpp b/src/map/Map.cpp index c7d75f1..fc664c1 100644 --- a/src/map/Map.cpp +++ b/src/map/Map.cpp @@ -23,27 +23,33 @@ Map::Map() , numAreas(0) , triggers(0) , numTriggers(0) +, entities(0) +, numEntities(0) , width(0) { } -const Area &Map::AreaAt(const Vector &offset) const { +const Area *Map::AreaAt(const Vector &offset) const { if (numAreas > 0) { Vector coords(TileCoordinates(offset)); Vector areaOffset(coords / areas[0].Size()); int areaIndex(areaOffset.Index(width)); if (areaIndex < numAreas) { - return areas[areaIndex]; + return areas + areaIndex; } } - throw std::out_of_range("area offset out of bounds"); + return 0; } -const Tile &Map::TileAt(const Vector &offset) const { - const Area &area(AreaAt(offset)); - Vector tileOffset(TileCoordinates(offset) % area.Size()); - return area.TileAt(tileOffset); +const Tile *Map::TileAt(const Vector &offset) const { + const Area *area(AreaAt(offset)); + if (area) { + Vector tileOffset(TileCoordinates(offset) % area->Size()); + return area->TileAt(tileOffset); + } else { + return 0; + } } Trigger *Map::TriggerAt(const geometry::Vector &offset) { @@ -78,6 +84,15 @@ void Map::RenderDebug(SDL_Surface *dest, const Vector &inOffset) const { Vector offset(inOffset + Vector::FromIndex(i, width) * area.Size() * tileset->Size()); area.RenderDebug(dest, tileset, offset); } + for (int i(0); i < numTriggers; ++i) { + Vector offset((triggers[i].TilePosition() * tileset->Size()) + inOffset); + SDL_Rect destRect; + destRect.x = offset.X() + (tileset->Width() / 4); + destRect.y = offset.Y() + (tileset->Height() / 4); + destRect.w = tileset->Width() / 2; + destRect.h = tileset->Height() / 2; + SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0x00, 0xFF, 0xFF)); + } } }