new: es pot definir el color de fonfo del titol

fix: el color de fondo de la intro ara ja canvia be cap al color de fondo del titol (abans soles sabia canviar cap al blanc)
This commit is contained in:
2025-07-14 18:11:02 +02:00
parent 7ac9b53630
commit d35032a42a
9 changed files with 39 additions and 2 deletions

View File

@@ -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 ---

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -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);

View File

@@ -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")
{

View File

@@ -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 ---

View File

@@ -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_);
}

View File

@@ -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);

View File

@@ -54,7 +54,7 @@ TiledBG::~TiledBG()
void TiledBG::fillTexture()
{
// Crea los objetos para pintar en la textura de fondo
auto tile = std::make_unique<Sprite>(Resource::get()->getTexture("title_bg_tile.png"), (SDL_FRect){0, 0, TILE_WIDTH_, TILE_HEIGHT_});
auto tile = std::make_unique<Sprite>(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_);

View File

@@ -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