Transició a surface acabada. Ja compila

This commit is contained in:
2025-03-04 12:30:19 +01:00
parent c4033e3663
commit 05f91b2a94
31 changed files with 376 additions and 1078 deletions

View File

@@ -415,7 +415,7 @@ Room::Room(const std::string &room_path, std::shared_ptr<ScoreboardData> data)
setAnimatedTiles();
// Crea la textura para el mapa de tiles de la habitación
map_surface_ = createTexture(Screen::get()->getRenderer(), PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT);
map_surface_ = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT);
// Pinta el mapa de la habitación en la textura
fillMapTexture();
@@ -424,9 +424,6 @@ Room::Room(const std::string &room_path, std::shared_ptr<ScoreboardData> data)
Screen::get()->setBorderColor(stringToColor(border_color_));
}
// Destructor
Room::~Room() { SDL_DestroyTexture(map_surface_); }
void Room::initializeRoom(const RoomData &room)
{
// Asignar valores a las variables miembro
@@ -477,9 +474,8 @@ void Room::initializeRoom(const RoomData &room)
void Room::fillMapTexture()
{
const Uint8 color = stringToColor(bg_color_);
SDL_SetRenderTarget(Screen::get()->getRenderer(), map_surface_);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), color.r, color.g, color.b, 0xFF);
SDL_RenderClear(Screen::get()->getRenderer());
Screen::get()->setRenderSurfaceData(map_surface_);
Screen::get()->clear(color);
// Los tileSetFiles son de 20x20 tiles. El primer tile es el 0. Cuentan hacia la derecha y hacia abajo
@@ -501,102 +497,103 @@ void Room::fillMapTexture()
surface_->render(x * TILE_SIZE_, y * TILE_SIZE_, &clip);
#ifdef DEBUG
if (Debug::get()->getEnabled())
/*if (Debug::get()->getEnabled())
{
if (clip.x != -TILE_SIZE_)
{
if (clip.x != -TILE_SIZE_)
{
clip.x = x * TILE_SIZE_;
clip.y = y * TILE_SIZE_;
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 64, 64, 64, 224);
SDL_RenderFillRect(Screen::get()->getRenderer(), &clip);
}
clip.x = x * TILE_SIZE_;
clip.y = y * TILE_SIZE_;
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 64, 64, 64, 224);
SDL_RenderFillRect(Screen::get()->getRenderer(), &clip);
}
}*/
#endif
}
}
#ifdef DEBUG
if (Debug::get()->getEnabled())
{
// BottomSurfaces
if (true)
{
for (auto l : bottom_floors_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 0, 0, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y, l.x2, l.y);
}
}
{ /*
// BottomSurfaces
if (true)
{
for (auto l : bottom_floors_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 0, 0, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y, l.x2, l.y);
}
}
// TopSurfaces
if (true)
{
for (auto l : top_floors_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 255, 0, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y, l.x2, l.y);
}
}
// TopSurfaces
if (true)
{
for (auto l : top_floors_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 255, 0, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y, l.x2, l.y);
}
}
// LeftSurfaces
if (true)
{
for (auto l : left_walls_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 128, 128, 255, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x, l.y1, l.x, l.y2);
}
}
// LeftSurfaces
if (true)
{
for (auto l : left_walls_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 128, 128, 255, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x, l.y1, l.x, l.y2);
}
}
// RightSurfaces
if (true)
{
for (auto l : right_walls_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 255, 0, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x, l.y1, l.x, l.y2);
}
}
// RightSurfaces
if (true)
{
for (auto l : right_walls_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 255, 0, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x, l.y1, l.x, l.y2);
}
}
// LeftSlopes
if (true)
{
for (auto l : left_slopes_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 255, 255, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y1, l.x2, l.y2);
}
}
// LeftSlopes
if (true)
{
for (auto l : left_slopes_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 255, 255, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y1, l.x2, l.y2);
}
}
// RightSlopes
if (true)
{
for (auto l : right_slopes_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 0, 255, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y1, l.x2, l.y2);
}
}
// RightSlopes
if (true)
{
for (auto l : right_slopes_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 0, 255, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y1, l.x2, l.y2);
}
}
// AutoSurfaces
if (true)
{
for (auto l : conveyor_belt_floors_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y, l.x2, l.y);
}
}
// AutoSurfaces
if (true)
{
for (auto l : conveyor_belt_floors_)
{
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y, l.x2, l.y);
}
}
*/
}
#endif
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
#endif
Screen::get()->setRenderSurfaceData(nullptr);
}
// Dibuja el mapa en pantalla
@@ -604,7 +601,7 @@ void Room::renderMap()
{
// Dibuja la textura con el mapa en pantalla
SDL_Rect dest = {0, 0, PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT};
SDL_RenderCopy(Screen::get()->getRenderer(), map_surface_, nullptr, &dest);
map_surface_->render(nullptr, &dest);
// Dibuja los tiles animados
#ifdef DEBUG