diff --git a/data/config/param_320x256.txt b/data/config/param_320x256.txt index c9f531f..e0763f0 100644 --- a/data/config/param_320x256.txt +++ b/data/config/param_320x256.txt @@ -40,6 +40,7 @@ title.press_start_position 180 # Posición Y del texto "Press Start" title.title_duration 800 # Duración de la pantalla de título (frames) title.arcade_edition_position 123 # Posición Y del subtítulo "Arcade Edition" title.title_c_c_position 80 # Posición Y del título principal +title.bg_color FF0000 # Color de fondo en la sección titulo ## --- BACKGROUND --- background.attenuate_color FFFFFF00 # Color de atenuación del fondo (RGBA hexadecimal) @@ -76,6 +77,7 @@ service_menu.drop_shadow false # ¿El menú de servicio tiene sombra? ## --- INTRO --- intro.bg_color 543149 # Color de fondo de la intro +intro.bg_color 00FFFF # Color de fondo de la intro intro.card_color CBDBFC # Color de las tarjetas en la intro ## --- DEBUG --- diff --git a/data/gfx/title/title_bg_tile_v2.png b/data/gfx/title/title_bg_tile_v2.png new file mode 100644 index 0000000..885a6b6 Binary files /dev/null and b/data/gfx/title/title_bg_tile_v2.png differ diff --git a/source/director.cpp b/source/director.cpp index 9ba1bd5..8cfd353 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -49,7 +49,7 @@ Director::Director(int argc, const char *argv[]) Section::name = Section::Name::GAME; Section::options = Section::Options::GAME_PLAY_1P; #elif DEBUG - Section::name = Section::Name::TITLE; + Section::name = Section::Name::INTRO; Section::options = Section::Options::GAME_PLAY_1P; #else // NORMAL GAME Section::name = Section::Name::LOGO; @@ -402,6 +402,7 @@ void Director::setFileList() // Texturas - Titulo Asset::get()->add(prefix + "/data/gfx/title/title_bg_tile.png", AssetType::BITMAP); + Asset::get()->add(prefix + "/data/gfx/title/title_bg_tile_v2.png", AssetType::BITMAP); Asset::get()->add(prefix + "/data/gfx/title/title_coffee.png", AssetType::BITMAP); Asset::get()->add(prefix + "/data/gfx/title/title_crisis.png", AssetType::BITMAP); Asset::get()->add(prefix + "/data/gfx/title/title_arcade_edition.png", AssetType::BITMAP); diff --git a/source/param.cpp b/source/param.cpp index 1bce33a..a9882a3 100644 --- a/source/param.cpp +++ b/source/param.cpp @@ -55,6 +55,7 @@ void initParam() param.title.title_duration = 800; param.title.arcade_edition_position = 123; param.title.title_c_c_position = 11; + param.title.bg_color = Color(255, 255, 255); // BACKGROUND param.background.attenuate_color = Color(255, 255, 255, 0); @@ -308,6 +309,11 @@ bool setParams(const std::string &var, const std::string &value) param.title.title_c_c_position = std::stoi(value); } + else if (var == "title.bg_color") + { + param.title.bg_color = Color::fromHex(value); + } + // BACKGROUND else if (var == "background.attenuate_color") { diff --git a/source/param.h b/source/param.h index a005842..605ced4 100644 --- a/source/param.h +++ b/source/param.h @@ -40,6 +40,7 @@ struct ParamTitle int title_duration; // Tiempo de inactividad del título int arcade_edition_position; // Posición del bitmap "Arcade Edition" int title_c_c_position; // Posición del bitmap "Coffee Crisis" + Color bg_color; // Color para los tiles de fondo }; // --- Parámetros del fondo --- diff --git a/source/sections/intro.cpp b/source/sections/intro.cpp index 19d8a64..0a808e7 100644 --- a/source/sections/intro.cpp +++ b/source/sections/intro.cpp @@ -500,6 +500,7 @@ void Intro::updatePostState() { tiled_bg_->stopGracefully(); + /* // Modifica el color del fondo hasta llegar a blanco if (bg_color_.r <= 253 || bg_color_.g <= 253 || bg_color_.b <= 253) // Garantiza que no se exceda de 255 al incrementar de 2 en 2 { @@ -509,6 +510,17 @@ void Intro::updatePostState() { bg_color_ = Color(255, 255, 255); // Asegura que bg_color_ no exceda el límite máximo } + */ + + if (bg_color_.isEqualTo(param.title.bg_color)) + { + // Ya hemos llegado al color objetivo + } + else + { + bg_color_ = bg_color_.approachTo(param.title.bg_color, 2); + } + tiled_bg_->setColor(bg_color_); } diff --git a/source/sections/title.cpp b/source/sections/title.cpp index f2d3db8..6ff4621 100644 --- a/source/sections/title.cpp +++ b/source/sections/title.cpp @@ -39,6 +39,7 @@ Title::Title() state_(TitleState::LOGO_ANIMATING) { // Configura objetos + tiled_bg_->setColor(param.title.bg_color); game_logo_->enable(); mini_logo_sprite_->setX(param.game.game_area.center_x - mini_logo_sprite_->getWidth() / 2); fade_->setColor(param.fade.color); diff --git a/source/tiled_bg.cpp b/source/tiled_bg.cpp index 2d97d3b..bc9bd11 100644 --- a/source/tiled_bg.cpp +++ b/source/tiled_bg.cpp @@ -54,7 +54,7 @@ TiledBG::~TiledBG() void TiledBG::fillTexture() { // Crea los objetos para pintar en la textura de fondo - auto tile = std::make_unique(Resource::get()->getTexture("title_bg_tile.png"), (SDL_FRect){0, 0, TILE_WIDTH_, TILE_HEIGHT_}); + auto tile = std::make_unique(Resource::get()->getTexture("title_bg_tile_v2.png"), (SDL_FRect){0, 0, TILE_WIDTH_, TILE_HEIGHT_}); // Prepara para dibujar sobre la textura auto temp = SDL_GetRenderTarget(renderer_); diff --git a/source/utils.h b/source/utils.h index 799fc48..f755cb7 100644 --- a/source/utils.h +++ b/source/utils.h @@ -100,6 +100,20 @@ struct Color return Color(r, g, b, a); } + + constexpr bool isEqualTo(const Color &other) const + { + return r == other.r && g == other.g && b == other.b && a == other.a; + } + + constexpr Color approachTo(const Color &target, int step = 1) const + { + Uint8 newR = (std::abs(r - target.r) <= step) ? target.r : (r < target.r ? r + step : r - step); + Uint8 newG = (std::abs(g - target.g) <= step) ? target.g : (g < target.g ? g + step : g - step); + Uint8 newB = (std::abs(b - target.b) <= step) ? target.b : (b < target.b ? b + step : b - step); + + return Color(newR, newG, newB, a); + } }; // Estructura para definir un color HSV