This commit is contained in:
2025-11-20 09:19:24 +01:00
parent 7d962ae752
commit 34840a64cf
5 changed files with 242 additions and 256 deletions

View File

@@ -56,6 +56,46 @@ void TilemapRenderer::render() {
}
#ifdef _DEBUG
// Renderiza las superficies de colisión en modo debug (función helper estática)
static void renderDebugCollisionSurfaces(const CollisionMap* collision_map) {
auto surface = Screen::get()->getRendererSurface();
// BottomSurfaces
for (auto l : collision_map->getBottomFloors()) {
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::BLUE));
}
// TopSurfaces
for (auto l : collision_map->getTopFloors()) {
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::RED));
}
// LeftSurfaces
for (auto l : collision_map->getLeftWalls()) {
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::GREEN));
}
// RightSurfaces
for (auto l : collision_map->getRightWalls()) {
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::MAGENTA));
}
// LeftSlopes
for (auto l : collision_map->getLeftSlopes()) {
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::CYAN));
}
// RightSlopes
for (auto l : collision_map->getRightSlopes()) {
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::YELLOW));
}
// AutoSurfaces (Conveyor Belts)
for (auto l : collision_map->getConveyorBeltFloors()) {
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::WHITE));
}
}
// Redibuja el tilemap (para actualizar modo debug)
void TilemapRenderer::redrawMap(const CollisionMap* collision_map) {
fillMapTexture(collision_map);
@@ -98,58 +138,8 @@ void TilemapRenderer::fillMapTexture(const CollisionMap* collision_map) {
#ifdef _DEBUG
// Pinta las superficies en el modo debug
if (Debug::get()->isEnabled()) {
auto surface = Screen::get()->getRendererSurface();
// BottomSurfaces
{
for (auto l : collision_map->getBottomFloors()) {
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::BLUE));
}
}
// TopSurfaces
{
for (auto l : collision_map->getTopFloors()) {
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::RED));
}
}
// LeftSurfaces
{
for (auto l : collision_map->getLeftWalls()) {
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::GREEN));
}
}
// RightSurfaces
{
for (auto l : collision_map->getRightWalls()) {
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::MAGENTA));
}
}
// LeftSlopes
{
for (auto l : collision_map->getLeftSlopes()) {
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::CYAN));
}
}
// RightSlopes
{
for (auto l : collision_map->getRightSlopes()) {
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::YELLOW));
}
}
// AutoSurfaces
{
for (auto l : collision_map->getConveyorBeltFloors()) {
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::WHITE));
}
}
renderDebugCollisionSurfaces(collision_map);
}
#endif // _DEBUG
Screen::get()->setRendererSurface(previous_renderer);
}