Transició a surface: game.cpp fet
This commit is contained in:
@@ -66,7 +66,6 @@ Game::Game(GameMode mode)
|
||||
Game::~Game()
|
||||
{
|
||||
ItemTracker::destroy();
|
||||
SDL_DestroyTexture(room_name_texture_);
|
||||
}
|
||||
|
||||
// Comprueba los eventos de la cola
|
||||
@@ -288,7 +287,7 @@ void Game::checkDebugEvents(const SDL_Event &event)
|
||||
void Game::renderRoomName()
|
||||
{
|
||||
// Dibuja la textura con el nombre de la habitación
|
||||
SDL_RenderCopy(Screen::get()->getRenderer(), room_name_texture_, nullptr, &room_name_rect_);
|
||||
room_name_surface_->render(nullptr, &room_name_rect_);
|
||||
}
|
||||
|
||||
// Cambia de habitación
|
||||
@@ -561,19 +560,17 @@ void Game::initStats()
|
||||
void Game::fillRoomNameTexture()
|
||||
{
|
||||
// Pone la textura como destino de renderizado
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), room_name_texture_);
|
||||
Screen::get()->setRenderSurfaceData(room_name_surface_);
|
||||
|
||||
// Rellena la textura de color
|
||||
const Color color = stringToColor(options.video.palette, "white");
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), color.r, color.g, color.b, 0xFF);
|
||||
SDL_RenderClear(Screen::get()->getRenderer());
|
||||
Screen::get()->clean(stringToColor("white"));
|
||||
|
||||
// Escribe el texto en la textura
|
||||
auto text = Resource::get()->getText("smb2");
|
||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, GAMECANVAS_CENTER_X, text->getCharacterSize() / 2, room_->getName(), 1, room_->getBGColor());
|
||||
|
||||
// Deja el renderizador por defecto
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
|
||||
Screen::get()->setRenderSurfaceData(nullptr);
|
||||
}
|
||||
|
||||
// Comprueba algunos logros
|
||||
@@ -663,8 +660,7 @@ void Game::initPlayer(const PlayerSpawn &spawn_point, std::shared_ptr<Room> room
|
||||
void Game::createRoomNameTexture()
|
||||
{
|
||||
auto text = Resource::get()->getText("smb2");
|
||||
room_name_texture_ = createTexture(Screen::get()->getRenderer(), options.game.width, text->getCharacterSize() * 2);
|
||||
SDL_SetTextureBlendMode(room_name_texture_, SDL_BLENDMODE_BLEND);
|
||||
room_name_surface_ = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), options.game.width, text->getCharacterSize() * 2);
|
||||
|
||||
// Establece el destino de la textura
|
||||
room_name_rect_ = {0, PLAY_AREA_HEIGHT, options.game.width, text->getCharacterSize() * 2};
|
||||
|
||||
Reference in New Issue
Block a user