}
}
+void Area::RenderDebug(SDL_Surface *dest, const graphics::Sprite *tileset, const Vector<int> &inOffset) 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]);
+
+ if (tile.BlocksNorth()) {
+ SDL_Rect destRect;
+ destRect.x = offset.X();
+ destRect.y = offset.Y();
+ destRect.w = tileset->Width();
+ destRect.h = 1;
+ SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+ }
+
+ if (tile.BlocksEast()) {
+ SDL_Rect destRect;
+ destRect.x = offset.X() + tileset->Width() - 1;
+ destRect.y = offset.Y();
+ destRect.w = 1;
+ destRect.h = tileset->Height();
+ SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+ }
+
+ if (tile.BlocksSouth()) {
+ SDL_Rect destRect;
+ destRect.x = offset.X();
+ destRect.y = offset.Y() + tileset->Height() - 1;
+ destRect.w = tileset->Width();
+ destRect.h = 1;
+ SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+ }
+
+ if (tile.BlocksWest()) {
+ SDL_Rect destRect;
+ destRect.x = offset.X();
+ destRect.y = offset.Y();
+ destRect.w = 1;
+ destRect.h = tileset->Height();
+ SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+ }
+ }
+}
+
}
}
}
+void Map::RenderDebug(SDL_Surface *dest, const Vector<int> &inOffset) const {
+ // TODO: skip invisible areas
+ for (int i(0); i < numAreas; ++i) {
+ const Area &area(areas[i]);
+ Vector<int> offset(inOffset + Vector<int>::FromIndex(i, width) * area.Size() * tileset->Size());
+ area.RenderDebug(dest, tileset, offset);
+ }
+}
+
}
, camera(100, 100, &tempTarget)
, walkingSpeed(64)
, nextDirection(-1)
-, afterLock(false) {
+, afterLock(false)
+, debug(false) {
}
} else {
nextDirection = -1;
}
+
+ if (input.JustPressed(Input::DEBUG_1)) {
+ debug = !debug;
+ }
}
void MapState::UpdateWorld(float deltaT) {
Vector<int> offset(camera.CalculateOffset());
map->Render(screen, offset);
+ if (debug) {
+ map->RenderDebug(screen, offset);
+ }
+
std::sort(entities.begin(), entities.end(), ZCompare);
for (std::vector<Entity *>::iterator i(entities.begin()), end(entities.end()); i != end; ++i) {
(*i)->Render(screen, offset);