From 241732752add4f956b188f4cf15f461b1e139950 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Wed, 5 Mar 2025 20:52:34 +0100 Subject: [PATCH] =?UTF-8?q?i=20per=20fi=20ja=20comen=C3=A7a=20a=20tornar?= =?UTF-8?q?=20tot=20a=20la=20normalitat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-2-8x.gif => ruzx-spectrum-revision-2.gif} | Bin ...ruzx-spectrum-8x.gif => ruzx-spectrum.gif} | Bin ...justed-8x.gif => zx-spectrum-adjusted.gif} | Bin .../{zx-spectrum-8x.gif => zx-spectrum.gif} | Bin .../{zxarne-5-2-8x.gif => zxarne-5-2.gif} | Bin data/player/player.gif | Bin 145 -> 145 bytes source/credits.cpp | 8 +++--- source/director.cpp | 10 ++++---- source/ending.cpp | 14 +++++----- source/ending2.cpp | 6 ++--- source/enemy.cpp | 2 ++ source/game.cpp | 4 +-- source/loading_screen.cpp | 2 +- source/notifier.cpp | 13 +++++----- source/player.cpp | 6 ++--- source/resource.cpp | 2 +- source/room.cpp | 4 +-- source/scoreboard.cpp | 4 +-- source/screen.cpp | 14 +++++----- source/screen.h | 2 +- source/surface.cpp | 18 ++++++------- source/surface.h | 9 ++----- source/text.cpp | 8 +++--- source/title.cpp | 6 ++--- source/utils.cpp | 24 +++++++++--------- 25 files changed, 75 insertions(+), 81 deletions(-) rename data/palette/{ruzx-spectrum-revision-2-8x.gif => ruzx-spectrum-revision-2.gif} (100%) rename data/palette/{ruzx-spectrum-8x.gif => ruzx-spectrum.gif} (100%) rename data/palette/{zx-spectrum-adjusted-8x.gif => zx-spectrum-adjusted.gif} (100%) rename data/palette/{zx-spectrum-8x.gif => zx-spectrum.gif} (100%) rename data/palette/{zxarne-5-2-8x.gif => zxarne-5-2.gif} (100%) diff --git a/data/palette/ruzx-spectrum-revision-2-8x.gif b/data/palette/ruzx-spectrum-revision-2.gif similarity index 100% rename from data/palette/ruzx-spectrum-revision-2-8x.gif rename to data/palette/ruzx-spectrum-revision-2.gif diff --git a/data/palette/ruzx-spectrum-8x.gif b/data/palette/ruzx-spectrum.gif similarity index 100% rename from data/palette/ruzx-spectrum-8x.gif rename to data/palette/ruzx-spectrum.gif diff --git a/data/palette/zx-spectrum-adjusted-8x.gif b/data/palette/zx-spectrum-adjusted.gif similarity index 100% rename from data/palette/zx-spectrum-adjusted-8x.gif rename to data/palette/zx-spectrum-adjusted.gif diff --git a/data/palette/zx-spectrum-8x.gif b/data/palette/zx-spectrum.gif similarity index 100% rename from data/palette/zx-spectrum-8x.gif rename to data/palette/zx-spectrum.gif diff --git a/data/palette/zxarne-5-2-8x.gif b/data/palette/zxarne-5-2.gif similarity index 100% rename from data/palette/zxarne-5-2-8x.gif rename to data/palette/zxarne-5-2.gif diff --git a/data/player/player.gif b/data/player/player.gif index 3c811dadbe4e2e247072978ce61cf00fb064933f..51f56dbb6e36edbf824909cba88a4846fabe2511 100644 GIT binary patch delta 32 lcmbQpIFV7<-P6s&JW+u`fT4i_1pfd3Kap33kzt}mBmjUw2yg%Z delta 32 ocmbQpIFXUp-P6s&JW+u`fT5g$VWO}KdjkUl!~g&PCt5@T0D3S8?EnA( diff --git a/source/credits.cpp b/source/credits.cpp index aa74121..0a6f0b8 100644 --- a/source/credits.cpp +++ b/source/credits.cpp @@ -29,10 +29,10 @@ Credits::Credits() Screen::get()->setBorderColor(stringToColor("black")); // Crea la textura para el texto que se escribe en pantalla - text_surface_ = std::make_shared(Screen::get()->getRendererSurface(), options.game.width, options.game.height); + text_surface_ = std::make_shared(options.game.width, options.game.height); // Crea la textura para cubrir el rexto - cover_surface_ = std::make_shared(Screen::get()->getRendererSurface(), options.game.width, options.game.height); + cover_surface_ = std::make_shared(options.game.width, options.game.height); // Escribe el texto en la textura fillTexture(); @@ -143,7 +143,7 @@ void Credits::fillTexture() // Rellena la textura de texto Screen::get()->setRendererSurface(text_surface_); - Screen::get()->clearSurface(stringToColor("black")); + text_surface_->clear(stringToColor("black")); auto text = Resource::get()->getText("smb2"); @@ -168,7 +168,7 @@ void Credits::fillTexture() // Rellena la textura que cubre el texto con color transparente Screen::get()->setRendererSurface(text_surface_); - Screen::get()->clearSurface(stringToColor("transparent")); + text_surface_->clear(stringToColor("transparent")); // Los primeros 8 pixels crea una malla auto surface = Screen::get()->getRendererSurface(); diff --git a/source/director.cpp b/source/director.cpp index ef49733..cd3235e 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -394,11 +394,11 @@ bool Director::setFileList() Asset::get()->add(prefix + "/data/font/8bithud.txt", AssetType::FONT); // Paletas - Asset::get()->add(prefix + "/data/palette/zx-spectrum-8x.gif", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/zx-spectrum-adjusted-8x.gif", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/ruzx-spectrum-8x.gif", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/ruzx-spectrum-revision-2-8x.gif", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/zxarne-5-2-8x.gif", AssetType::PALETTE); + Asset::get()->add(prefix + "/data/palette/zx-spectrum.gif", AssetType::PALETTE); + Asset::get()->add(prefix + "/data/palette/zx-spectrum-adjusted.gif", AssetType::PALETTE); + Asset::get()->add(prefix + "/data/palette/ruzx-spectrum.gif", AssetType::PALETTE); + Asset::get()->add(prefix + "/data/palette/ruzx-spectrum-revision-2.gif", AssetType::PALETTE); + Asset::get()->add(prefix + "/data/palette/zxarne-5-2.gif", AssetType::PALETTE); // Shaders Asset::get()->add(prefix + "/data/shaders/crtpi_192.glsl", AssetType::DATA); diff --git a/source/ending.cpp b/source/ending.cpp index 3879b08..1db3db1 100644 --- a/source/ending.cpp +++ b/source/ending.cpp @@ -43,7 +43,7 @@ Ending::Ending() Screen::get()->setBorderColor(stringToColor("black")); // Crea la textura para cubrir el texto - cover_surface_ = std::make_shared(Screen::get()->getRendererSurface(), options.game.width, options.game.height + 8); + cover_surface_ = std::make_shared(options.game.width, options.game.height + 8); // Rellena la textura para la cortinilla fillCoverTexture(); @@ -172,7 +172,7 @@ void Ending::iniTexts() EndingSurface st; // Crea la textura - st.image_surface = std::make_shared(Screen::get()->getRendererSurface(), WIDTH, HEIGHT); + st.image_surface = std::make_shared(WIDTH, HEIGHT); Screen::get()->setRendererSurface(st.image_surface); text->writeDX(TEXT_STROKE, 2, 2, txt.caption, 1, color, 2, color); @@ -181,11 +181,11 @@ void Ending::iniTexts() st.image_sprite->setPosition((options.game.width - st.image_surface->getWidth()) / 2, txt.pos); // Crea la cover_surface - st.cover_surface = std::make_shared(Screen::get()->getRendererSurface(), WIDTH, HEIGHT + 8); + st.cover_surface = std::make_shared(WIDTH, HEIGHT + 8); Screen::get()->setRendererSurface(st.cover_surface); // Rellena la cover_surface con color transparente - Screen::get()->clearSurface(stringToColor("transparent")); + st.cover_surface->clear(stringToColor("transparent")); // Crea una malla de 8 pixels de alto auto surface = Screen::get()->getRendererSurface(); @@ -248,11 +248,11 @@ void Ending::iniPics() sp.image_sprite->setPosition((options.game.width - WIDTH) / 2, pic.pos); // Crea la cover_surface - sp.cover_surface = std::make_shared(Screen::get()->getRendererSurface(), WIDTH, HEIGHT + 8); + sp.cover_surface = std::make_shared(WIDTH, HEIGHT + 8); Screen::get()->setRendererSurface(sp.cover_surface); // Rellena la cover_surface con color transparente - Screen::get()->clearSurface(stringToColor("transparent")); + sp.cover_surface->clear(stringToColor("transparent")); // Crea una malla en los primeros 8 pixels auto surface = Screen::get()->getRendererSurface(); @@ -473,7 +473,7 @@ void Ending::fillCoverTexture() { // Rellena la textura que cubre el texto con color transparente Screen::get()->setRendererSurface(cover_surface_); - Screen::get()->clearSurface(stringToColor("transparent")); + cover_surface_->clear(stringToColor("transparent")); // Los primeros 8 pixels crea una malla const Uint8 color = stringToColor("black"); diff --git a/source/ending2.cpp b/source/ending2.cpp index 25099b1..5862fc0 100644 --- a/source/ending2.cpp +++ b/source/ending2.cpp @@ -423,7 +423,7 @@ void Ending2::createSpriteTexts() const int Y = sprites_.at(i)->getPosY() + sprites_.at(i)->getHeight() + DIST_SPRITE_TEXT_; // Crea la surface - auto surface = std::make_shared(Screen::get()->getRendererSurface(), W, H); + auto surface = std::make_shared(W, H); Screen::get()->setRendererSurface(surface); text->write(0, 0, txt); @@ -455,7 +455,7 @@ void Ending2::createTexts() const int y = options.game.height + (text->getCharacterSize() * (i * 2)); // Crea la surface - auto surface = std::make_shared(Screen::get()->getRendererSurface(), w, h); + auto surface = std::make_shared(w, h); Screen::get()->setRendererSurface(surface); text->write(0, 0, list[i]); @@ -484,7 +484,7 @@ void Ending2::createTexts() const int y = START + (text->getCharacterSize() * (i * 2)); // Crea la surface - auto surface = std::make_shared(Screen::get()->getRendererSurface(), w, h); + auto surface = std::make_shared(w, h); Screen::get()->setRendererSurface(surface); text->write(0, 0, list[i]); diff --git a/source/enemy.cpp b/source/enemy.cpp index fd352f8..40369a7 100644 --- a/source/enemy.cpp +++ b/source/enemy.cpp @@ -31,6 +31,8 @@ Enemy::Enemy(const EnemyData &enemy) collider_ = getRect(); + color_ = stringToColor(color_string_); + // Coloca un frame al azar o el designado sprite_->setCurrentAnimationFrame((enemy.frame == -1) ? (rand() % sprite_->getCurrentAnimationSize()) : enemy.frame); } diff --git a/source/game.cpp b/source/game.cpp index 3074cf9..f1a1fac 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -565,7 +565,7 @@ void Game::fillRoomNameTexture() Screen::get()->setRendererSurface(room_name_surface_); // Rellena la textura de color - Screen::get()->clearSurface(stringToColor("white")); + room_name_surface_->clear(stringToColor("white")); // Escribe el texto en la textura auto text = Resource::get()->getText("smb2"); @@ -662,7 +662,7 @@ void Game::initPlayer(const PlayerSpawn &spawn_point, std::shared_ptr room void Game::createRoomNameTexture() { auto text = Resource::get()->getText("smb2"); - room_name_surface_ = std::make_shared(Screen::get()->getRendererSurface(), options.game.width, text->getCharacterSize() * 2); + room_name_surface_ = std::make_shared(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}; diff --git a/source/loading_screen.cpp b/source/loading_screen.cpp index 67566a2..d34ce8e 100644 --- a/source/loading_screen.cpp +++ b/source/loading_screen.cpp @@ -22,7 +22,7 @@ LoadingScreen::LoadingScreen() color_loading_screen_surface_(Resource::get()->getSurface("loading_screen_color.gif")), mono_loading_screen_sprite_(std::make_shared(mono_loading_screen_surface_, 0, 0, mono_loading_screen_surface_->getWidth(), mono_loading_screen_surface_->getHeight())), color_loading_screen_sprite_(std::make_shared(color_loading_screen_surface_, 0, 0, color_loading_screen_surface_->getWidth(), color_loading_screen_surface_->getHeight())), - screen_surface_(std::make_shared(Screen::get()->getRendererSurface(), options.game.width, options.game.height)) + screen_surface_(std::make_shared(options.game.width, options.game.height)) { // Configura la superficie donde se van a pintar los sprites screen_surface_->clear(stringToColor("white")); diff --git a/source/notifier.cpp b/source/notifier.cpp index b4e2228..4e42fae 100644 --- a/source/notifier.cpp +++ b/source/notifier.cpp @@ -234,32 +234,31 @@ void Notifier::show(std::vector texts, NotificationText text_is, in n.rect = {desp_h, y_pos, width, height}; // Crea la textura - n.surface = std::make_shared(Screen::get()->getRendererSurface(), width, height); + n.surface = std::make_shared(width, height); // Prepara para dibujar en la textura Screen::get()->setRendererSurface(n.surface); // Dibuja el fondo de la notificación SDL_Rect rect; - auto surface = Screen::get()->getRendererSurface(); if (shape == NotificationShape::ROUNDED) { rect = {4, 0, width - (4 * 2), height}; - surface->fillRect(&rect, bg_color_); + n.surface->fillRect(&rect, bg_color_); rect = {4 / 2, 1, width - 4, height - 2}; - surface->fillRect(&rect, bg_color_); + n.surface->fillRect(&rect, bg_color_); rect = {1, 4 / 2, width - 2, height - 4}; - surface->fillRect(&rect, bg_color_); + n.surface->fillRect(&rect, bg_color_); rect = {0, 4, width, height - (4 * 2)}; - surface->fillRect(&rect, bg_color_); + n.surface->fillRect(&rect, bg_color_); } else if (shape == NotificationShape::SQUARED) { - Screen::get()->clearSurface(bg_color_); + n.surface->clear(bg_color_); } // Dibuja el icono de la notificación diff --git a/source/player.cpp b/source/player.cpp index a01e504..729f722 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -712,12 +712,12 @@ void Player::applySpawnValues(const PlayerSpawn &spawn) } // Inicializa el sprite del jugador -void Player::initSprite(const std::string &texture_path, const std::string &animations_path) +void Player::initSprite(const std::string &surface_path, const std::string &animations_path) { - auto texture = Resource::get()->getSurface(texture_path); + auto surface = Resource::get()->getSurface(surface_path); auto animations = Resource::get()->getAnimations(animations_path); - sprite_ = std::make_shared(texture, animations); + sprite_ = std::make_shared(surface, animations); sprite_->setWidth(WIDTH_); sprite_->setHeight(HEIGHT_); sprite_->setCurrentAnimation("walk"); diff --git a/source/resource.cpp b/source/resource.cpp index d305339..0a0b48a 100644 --- a/source/resource.cpp +++ b/source/resource.cpp @@ -247,7 +247,7 @@ void Resource::loadSurfaces() for (const auto &l : list) { auto name = getFileName(l); - surfaces_.emplace_back(ResourceSurface(name, std::make_shared(Screen::get()->getRendererSurface(), l))); + surfaces_.emplace_back(ResourceSurface(name, std::make_shared(l))); updateLoadingProgress(); } } diff --git a/source/room.cpp b/source/room.cpp index b950451..41242a2 100644 --- a/source/room.cpp +++ b/source/room.cpp @@ -415,7 +415,7 @@ Room::Room(const std::string &room_path, std::shared_ptr data) setAnimatedTiles(); // Crea la textura para el mapa de tiles de la habitación - map_surface_ = std::make_shared(Screen::get()->getRendererSurface(), PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT); + map_surface_ = std::make_shared(PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT); // Pinta el mapa de la habitación en la textura fillMapTexture(); @@ -475,7 +475,7 @@ void Room::fillMapTexture() { const Uint8 color = stringToColor(bg_color_); Screen::get()->setRendererSurface(map_surface_); - Screen::get()->clearSurface(color); + map_surface_->clear(color); // Los tileSetFiles son de 20x20 tiles. El primer tile es el 0. Cuentan hacia la derecha y hacia abajo diff --git a/source/scoreboard.cpp b/source/scoreboard.cpp index 33feaf4..890ea1c 100644 --- a/source/scoreboard.cpp +++ b/source/scoreboard.cpp @@ -27,7 +27,7 @@ Scoreboard::Scoreboard(std::shared_ptr data) player_sprite_ = std::make_shared(player_texture, player_animations); player_sprite_->setCurrentAnimation("walk_menu"); - surface_ = std::make_shared(Screen::get()->getRendererSurface(), SURFACE_WIDTH_, SURFACE_HEIGHT_); + surface_ = std::make_shared(SURFACE_WIDTH_, SURFACE_HEIGHT_); surface_dest_ = {0, options.game.height - SURFACE_HEIGHT_, SURFACE_WIDTH_, SURFACE_HEIGHT_}; // Inicializa las variables @@ -139,7 +139,7 @@ void Scoreboard::fillTexture() Screen::get()->setRendererSurface(surface_); // Limpia la textura - Screen::get()->clearSurface(stringToColor("black")); + surface_->clear(stringToColor("black")); // Anclas constexpr int LINE1 = BLOCK; diff --git a/source/screen.cpp b/source/screen.cpp index 36dcbd8..01c413c 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -75,13 +75,14 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer) } // Crea la surface donde se dibujan los graficos del juego - game_surface_ = std::make_shared(nullptr, options.game.width, options.game.height); + game_surface_ = std::make_shared(options.game.width, options.game.height); game_surface_->loadPalette(palettes_.front()); // Crea la surface donde se dibujan los graficos del juego - border_surface_ = std::make_shared(nullptr, options.game.width + options.video.border.width * 2, options.game.height + options.video.border.height * 2); + border_surface_ = std::make_shared(options.game.width + options.video.border.width * 2, options.game.height + options.video.border.height * 2); border_surface_->loadPalette(palettes_.front()); + // Establece la surface que actuará como renderer para recibir las llamadas a render() renderer_surface_ = std::make_shared>(game_surface_); // Establece el modo de video @@ -127,11 +128,12 @@ void Screen::startDrawOnBorder() // Vuelca el contenido del renderizador en pantalla void Screen::render() { + // Renderiza sobre game_surface_ los overlays + //renderNotifications(); + // Copia la surface a game_texture_ game_surface_->copyToTexture(renderer_, game_texture_); - // Renderiza sobre gameCanvas los overlays - // renderNotifications(); // Si está el borde activo, vuelca gameCanvas sobre borderCanvas if (options.video.border.enabled) @@ -381,9 +383,7 @@ void Screen::resetShaders() // Establece el renderizador para las surfaces void Screen::setRendererSurface(std::shared_ptr surface) { - (surface) ? - renderer_surface_ = std::make_shared>(surface): - renderer_surface_ = std::make_shared>(game_surface_); + (surface) ? renderer_surface_ = std::make_shared>(surface) : renderer_surface_ = std::make_shared>(game_surface_); } // Cambia la paleta diff --git a/source/screen.h b/source/screen.h index c04a0a3..906c456 100644 --- a/source/screen.h +++ b/source/screen.h @@ -32,7 +32,7 @@ private: SDL_Texture *border_texture_; // Textura donde se dibuja el borde del juego std::shared_ptr game_surface_; // Surface principal para manejar game_surface_data_ std::shared_ptr border_surface_; // Surface para pintar el el borde de la pantalla - std::shared_ptr> renderer_surface_; + std::shared_ptr> renderer_surface_; // Puntero a la Surface que actua // Variables int window_width_; // Ancho de la pantalla o ventana diff --git a/source/surface.cpp b/source/surface.cpp index e0f8b21..b3d3e0a 100644 --- a/source/surface.cpp +++ b/source/surface.cpp @@ -9,17 +9,15 @@ #include // for vector #include "asset.h" // for Asset #include "screen.h" -#include "gif.h" // for LoadGif, LoadPalette +#include "gif.h" // for LoadGif, LoadPalette // Constructor -Surface::Surface(std::shared_ptr surface_dest, int w, int h) - : surface_dest_(surface_dest), - surface_data_(std::make_shared(w, h)), - transparent_color_(0){} +Surface::Surface(int w, int h) + : surface_data_(std::make_shared(w, h)), + transparent_color_(0) {} -Surface::Surface(std::shared_ptr surface_dest, const std::string &file_path) - : surface_dest_(surface_dest), - transparent_color_(0) +Surface::Surface(const std::string &file_path) + : transparent_color_(0) { SurfaceData loadedData = loadSurface(file_path); surface_data_ = std::make_shared(std::move(loadedData)); @@ -209,7 +207,7 @@ void Surface::render(int dx, int dy, int sx, int sy, int w, int h) void Surface::render(int x, int y, SDL_Rect *srcRect, SDL_RendererFlip flip) { auto surface_data = Screen::get()->getRendererSurface()->getSurfaceData(); - + // Determina la región de origen (clip) a renderizar int sx = (srcRect) ? srcRect->x : 0; int sy = (srcRect) ? srcRect->y : 0; @@ -349,7 +347,7 @@ void Surface::renderWithColorReplace(int x, int y, Uint8 source_color, Uint8 tar // Vuelca la superficie a una textura void Surface::copyToTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - if (!renderer || !texture) + if (!renderer || !texture || !surface_data_) { throw std::runtime_error("Renderer or texture is null."); } diff --git a/source/surface.h b/source/surface.h index 79e4bd4..76aae66 100644 --- a/source/surface.h +++ b/source/surface.h @@ -60,15 +60,14 @@ struct SurfaceData class Surface { private: - std::shared_ptr surface_dest_; // Surface remota donde dibujar la surface_data_ std::shared_ptr surface_data_; // Datos a dibujar std::array palette_; // Paleta para volcar la SurfaceData a una Textura int transparent_color_; // Indice de la paleta que se omite en la copia de datos public: // Constructor - Surface(std::shared_ptr surface_dest, int w, int h); - Surface(std::shared_ptr surface_dest, const std::string &file_path); + Surface(int w, int h); + Surface(const std::string &file_path); // Destructor ~Surface() = default; @@ -111,10 +110,6 @@ public: // Dibuja una linea void drawLine(int x1, int y1, int x2, int y2, Uint8 color); - // Métodos para gestionar surface_dest_ - std::shared_ptr getSurfaceDest() const { return surface_dest_; } - void setSurfaceDest(std::shared_ptr new_surface_dest) { surface_dest_ = new_surface_dest; } - // Metodos para gestionar surface_data_ std::shared_ptr getSurfaceData() const { return surface_data_; } void setSurfaceData(std::shared_ptr new_data) { surface_data_ = new_data; } diff --git a/source/text.cpp b/source/text.cpp index 62af92a..a8ca633 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -146,9 +146,9 @@ std::shared_ptr Text::writeToSurface(const std::string &text, int zoom, { auto width = lenght(text, kerning) * zoom; auto height = box_height_ * zoom; - auto surface = std::make_shared(Screen::get()->getRendererSurface(), width, height); + auto surface = std::make_shared(width, height); Screen::get()->setRendererSurface(surface); - Screen::get()->clearSurface(stringToColor("transparent")); + surface->clear(stringToColor("transparent")); write(0, 0, text, kerning); Screen::get()->setRendererSurface(nullptr); @@ -160,9 +160,9 @@ std::shared_ptr Text::writeDXToSurface(Uint8 flags, const std::string & { auto width = Text::lenght(text, kerning) + shadow_distance; auto height = box_height_ + shadow_distance; - auto surface = std::make_shared(Screen::get()->getRendererSurface(), width, height); + auto surface = std::make_shared(width, height); Screen::get()->setRendererSurface(surface); - Screen::get()->clearSurface(stringToColor("transparent")); + surface->clear(stringToColor("transparent")); writeDX(flags, 0, 0, text, kerning, textColor, shadow_distance, shadow_color, lenght); Screen::get()->setRendererSurface(nullptr); diff --git a/source/title.cpp b/source/title.cpp index d1a24a1..66fa81d 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -25,7 +25,7 @@ Title::Title() : title_logo_surface_(Resource::get()->getSurface("title_logo.gif")), title_logo_sprite_(std::make_shared(title_logo_surface_, 0, 0, title_logo_surface_->getWidth(), title_logo_surface_->getHeight())), - bg_surface_(std::make_shared(Screen::get()->getRendererSurface(), options.game.width, options.game.height)) + bg_surface_(std::make_shared(options.game.width, options.game.height)) { // Carga la surface con los gráficos de la pantalla de carga pInit(Screen::get()->getRenderer(), 256, 128); @@ -347,14 +347,14 @@ void Title::createCheevosTexture() constexpr int CHEEVOS_PADDING = 10; const int CHEEVO_HEIGHT = CHEEVOS_PADDING + (TEXT->getCharacterSize() * 2) + 1; const int CHEEVOS_TEXTURE_HEIGHT = (CHEEVO_HEIGHT * CHEEVOS_LIST.size()) + 2 + TEXT->getCharacterSize() + 8; - cheevos_surface_ = std::make_shared(Screen::get()->getRendererSurface(), CHEEVOS_TEXTURE_WIDTH, CHEEVOS_TEXTURE_HEIGHT); + cheevos_surface_ = std::make_shared(CHEEVOS_TEXTURE_WIDTH, CHEEVOS_TEXTURE_HEIGHT); // Prepara para dibujar sobre la textura Screen::get()->setRendererSurface(cheevos_surface_); // Rellena la textura con color sólido const Uint8 CHEEVOS_BG_COLOR = stringToColor("black"); - Screen::get()->clearSurface(CHEEVOS_BG_COLOR); + cheevos_surface_->clear(CHEEVOS_BG_COLOR); // Escribe la lista de logros en la textura const std::string CHEEVOS_OWNER = "ACHIEVEMENTS"; diff --git a/source/utils.cpp b/source/utils.cpp index 287a7f2..db6da66 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -366,18 +366,18 @@ Uint8 stringToColor(const std::string &str) {"transparent", 0}, {"black", 1}, {"bright_black", 2}, - {"blue", 3}, - {"bright_blue", 4}, - {"red", 5}, - {"bright_red", 6}, - {"magenta", 7}, - {"bright_magenta", 8}, - {"green", 9}, - {"bright_green", 10}, - {"cyan", 11}, - {"bright_cyan", 12}, - {"yellow", 13}, - {"bright_yellow", 14}, + {"red", 3}, + {"bright_red", 4}, + {"green", 5}, + {"bright_green", 6}, + {"yellow", 7}, + {"bright_yellow", 8}, + {"blue", 9}, + {"bright_blue", 10}, + {"magenta", 11}, + {"bright_magenta", 12}, + {"cyan", 13}, + {"bright_cyan", 14}, {"white", 15}, {"bright_white", 16}};