From 59936f13eb35c670eb141c1a9b68f3cd005f8b84 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 26 Jan 2025 17:48:10 +0100 Subject: [PATCH] Arreglos estetics i de colorets en hiscore_table.cpp --- data/font/04b_25.png | Bin 3237 -> 3126 bytes data/lang/ba_BA.txt | 4 +- source/game.cpp | 11 ++- source/hiscore_table.cpp | 161 +++++++++++++++++++++++++++++---------- source/hiscore_table.h | 40 ++++++---- source/instructions.cpp | 1 - source/tabe.cpp | 1 + source/tabe.h | 5 +- source/text.cpp | 2 +- source/texture.cpp | 4 + source/texture.h | 18 +++-- source/utils.cpp | 1 + source/utils.h | 27 ++++++- 13 files changed, 204 insertions(+), 71 deletions(-) diff --git a/data/font/04b_25.png b/data/font/04b_25.png index dfc7409f4a5a21628b7ffb3257ddb560b3f05374..a87d2a98ac75e8b5a3abdad4681f97c7646907d9 100644 GIT binary patch delta 3109 zcmV+=4BGRh8MYXZFnyOrBK5QS%b)Po`yqeL~J0VP|3N>Bw#)PQPG z;xZgL@Nu-s25vxq@bBo1AUx&)fDg|-XV1!BUS1F&NJ{!R1aP@rE~!EY_YlH;>UOx+ zrH#dmJLL6xebf4+>(F{}+4K2~|5f$I>(}I=Bpzvh#(C1d)PH1J+Ug<-A>2PdKkuKP zpQ0mt?31iR>!r)aKRIu_eruk@BRylrdD6bLj-jNj=wI7a!M9c`+U<7cjw!7pgm5Qk z6Nq1zCInqpnk)6>@=9&Av?-S--6n4PQsW?Ga4s9*@->HTKXf`hTe-xU?@&oPLn_Yf4Re>Da~6o(boYr=CdGBPiVn z&IW}L?uWwxe*O9d008mp%jHt^ACE^k91Z{gaJgI_uL07X8t38qx7%&?(jfNGtjpz6 z>@UsWVt*dCk1ISIQ9oDGNl*6|It~E!{YUc&VSH&$)gw++6R#C7pbJ%fR~aqk8_5X zY*(C@`_QFzp6Sx==g*&y*F8?nRCt8>{{1@u0Dt`X^9Shb(ou%ClS=C2Y;WAoR94G= z%H?s!gKkf)FIq`+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xder20xlTqY3fNk@*yZ|@RE_?2 zx&CDBYJcM|dX$BAxlT>Ha$LRxxmwriteToTexture(caption, 1, -4)); } } + + // Modifica el color de fondo al llegar a la Fase 10 + if (Stage::number == 9) + { + background_->setColor(Color(0xdd, 0x19, 0x1d).darken()); + background_->setAlpha(96); + } } } @@ -365,6 +372,7 @@ void Game::updateGameStateCompleted() balloon_manager_->destroyAllBalloons(); // Destruye a todos los globos destroyAllItems(); // Destruye todos los items Stage::power = 0; // Vuelve a dejar el poder a cero, por lo que hubiera podido subir al destruir todos los globos + background_->setAlpha(0); // Elimina el tono rojo de las últimas pantallas } // Comienza las celebraciones @@ -1261,7 +1269,8 @@ void Game::checkEvents() { auto_pop_balloons_ = !auto_pop_balloons_; Notifier::get()->showText({"auto advance: " + boolToString(auto_pop_balloons_)}); - balloon_manager_->destroyAllBalloons(); + if (auto_pop_balloons_) + balloon_manager_->destroyAllBalloons(); balloon_manager_->setDeployBalloons(!auto_pop_balloons_); break; } diff --git a/source/hiscore_table.cpp b/source/hiscore_table.cpp index b697ef1..3bf6b11 100644 --- a/source/hiscore_table.cpp +++ b/source/hiscore_table.cpp @@ -4,23 +4,28 @@ #include // Para SDL_PIXELFORMAT_RGBA8888 #include // Para SDL_GetTicks #include // Para SDL_WINDOWEVENT_SIZE_CHANGED +#include // Para rand #include // Para max +#include // Para function #include // Para vector #include "background.h" // Para Background #include "fade.h" // Para Fade, FadeMode, FadeType -#include "global_inputs.h" // Para check +#include "global_inputs.h" // Para check, update #include "input.h" // Para Input #include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state #include "lang.h" // Para getText #include "manage_hiscore_table.h" // Para HiScoreEntry +#include "mouse.h" // Para handleEvent #include "options.h" // Para Options, OptionsGame, options #include "param.h" // Para Param, param, ParamGame, ParamFade +#include "path_sprite.h" // Para PathSprite, Path, PathType #include "resource.h" // Para Resource #include "screen.h" // Para Screen -#include "section.h" // Para Name, name, Options, options -#include "text.h" // Para Text, TEXT_CENTER, TEXT_SHADOW -#include "utils.h" // Para Color, Zone, fade_color, orange_color -#include "mouse.h" +#include "section.h" // Para Name, name, Options, options, Attr... +#include "sprite.h" // Para Sprite +#include "text.h" // Para Text, TEXT_COLOR, TEXT_SHADOW +#include "texture.h" // Para Texture +#include "utils.h" // Para Color, easeOutQuint, fade_color // Constructor HiScoreTable::HiScoreTable() @@ -28,30 +33,17 @@ HiScoreTable::HiScoreTable() backbuffer_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height)), fade_(std::make_unique()), background_(std::make_unique()), - text_(Resource::get()->getText("smb2")), counter_(0), ticks_(0), view_area_({0, 0, param.game.width, param.game.height}), - fade_mode_(FadeMode::IN) + fade_mode_(FadeMode::IN), + background_fade_color_(Color(0, 0, 0)) { - // Inicializa el resto de variables + // Inicializa el resto section::name = section::Name::HI_SCORE_TABLE; - - // Inicializa objetos SDL_SetTextureBlendMode(backbuffer_, SDL_BLENDMODE_BLEND); - background_->setPos(param.game.game_area.rect); - background_->setCloudsSpeed(-0.1f); - background_->setGradientNumber(1); - background_->setTransition(0.8f); - background_->setSunProgression(1.0f); - background_->setMoonProgression(0.6f); - fade_->setColor(fade_color.r, fade_color.g, fade_color.b); - fade_->setType(FadeType::RANDOM_SQUARE); - fade_->setPostDuration(param.fade.post_duration); - fade_->setMode(fade_mode_); - fade_->activate(); - - // Crea los sprites con los textos + initFade(); + initBackground(); createSprites(); } @@ -97,7 +89,7 @@ void HiScoreTable::update() if (counter_ == 150) { - background_->setColor(Color(0, 0, 0)); + background_->setColor(background_fade_color_.darken()); background_->setAlpha(96); } @@ -161,8 +153,6 @@ void HiScoreTable::render() // Recarga todas las texturas void HiScoreTable::reloadTextures() { - text_->reLoadTexture(); - fillTexture(); } // Comprueba los eventos @@ -268,6 +258,9 @@ std::string HiScoreTable::format(int number) // Crea los sprites con los textos void HiScoreTable::createSprites() { + auto header_text = Resource::get()->getText("04b_25"); + auto entry_text = Resource::get()->getText("smb2"); + // Obtiene el tamaño de la textura int backbuffer_width; int backbuffer_height; @@ -276,32 +269,34 @@ void HiScoreTable::createSprites() // Hay 27 letras - 7 de puntos quedan 20 caracteres 20 - name_lenght 0 num_dots constexpr int max_names = 10; constexpr int space_between_header = 32; - const int space_between_lines = text_->getCharacterSize() * 2; - const int size = space_between_header + space_between_lines * (max_names - 1) + text_->getCharacterSize(); + const int space_between_lines = entry_text->getCharacterSize() * 2; + const int size = space_between_header + space_between_lines * (max_names - 1) + entry_text->getCharacterSize(); const int first_line = (param.game.height - size) / 2; // Crea el sprite para el texto de cabecera - header_ = std::make_unique(text_->writeDXToTexture(TEXT_COLOR | TEXT_SHADOW, lang::getText(42), 1, orange_color, 1, shdw_txt_color)); + header_ = std::make_unique(header_text->writeDXToTexture(TEXT_COLOR, lang::getText(42), -2, background_fade_color_.getInverse().lighten(25))); header_->setPosition(param.game.game_area.center_x - (header_->getWidth() / 2), first_line); // Crea los sprites para las entradas en la tabla de puntuaciones + const int animation = rand() % 4; for (int i = 0; i < max_names; ++i) { - const auto name_lenght = options.game.hi_score_table.at(i).name.length(); + const auto table_position = (i + 1 >= 10) ? format(i + 1) + ". " : " " + format(i + 1) + ". "; const auto score = format(options.game.hi_score_table.at(i).score); - const auto score_lenght = score.size(); - const auto num_dots = 25 - name_lenght - score_lenght; + const auto num_dots = 25 - table_position.size() - options.game.hi_score_table.at(i).name.size() - score.size(); std::string dots; for (int j = 0; j < (int)num_dots; ++j) { dots = dots + "."; } - const auto line = options.game.hi_score_table.at(i).name + dots + score; + const auto line = table_position + options.game.hi_score_table.at(i).name + dots + score; - entry_names_.emplace_back(std::make_shared(text_->writeDXToTexture(TEXT_SHADOW, line, 1, orange_color, 1, shdw_txt_color))); - if (false) + entry_names_.emplace_back(std::make_shared(entry_text->writeDXToTexture(TEXT_SHADOW, line, 1, orange_color, 1, shdw_txt_color))); + switch (animation) { - if (i % 1 == 0) + case 0: // Ambos lados alternativamente + { + if (i % 2 == 0) { entry_names_.back()->addPath( -entry_names_.back()->getWidth(), @@ -325,9 +320,38 @@ void HiScoreTable::createSprites() 0); entry_names_.back()->setPosition(backbuffer_width, 0); } + break; } - if (true) + case 1: // Entran por la izquierda + { + entry_names_.back()->addPath( + -entry_names_.back()->getWidth(), + (backbuffer_width - entry_names_.back()->getWidth()) / 2, + PathType::HORIZONTAL, + (i * space_between_lines) + first_line + space_between_header, + 80, + easeOutQuint, + 0); + entry_names_.back()->setPosition(-entry_names_.back()->getWidth(), 0); + break; + } + + case 2: // Entran por la derecha + { + entry_names_.back()->addPath( + backbuffer_width, + (backbuffer_width - entry_names_.back()->getWidth()) / 2, + PathType::HORIZONTAL, + (i * space_between_lines) + first_line + space_between_header, + 80, + easeOutQuint, + 0); + entry_names_.back()->setPosition(backbuffer_width, 0); + break; + } + + case 3: // Entran desde la parte inferior { entry_names_.back()->addPath( backbuffer_height, @@ -339,14 +363,18 @@ void HiScoreTable::createSprites() 0); entry_names_.back()->setPosition(0, backbuffer_height); } + + default: + break; + } } } // Actualiza las posiciones de los sprites de texto void HiScoreTable::updateSprites() { - constexpr int init_counter = 220; - const int counter_between_entries = text_->getCharacterSize() * 2; + constexpr int init_counter = 190; + const int counter_between_entries = 16; if (counter_ >= init_counter) { const int counter2 = counter_ - init_counter; @@ -363,4 +391,59 @@ void HiScoreTable::updateSprites() { entry->update(); } +} + +// Inicializa el fade +void HiScoreTable::initFade() +{ + fade_->setColor(fade_color.r, fade_color.g, fade_color.b); + fade_->setType(FadeType::RANDOM_SQUARE); + fade_->setPostDuration(param.fade.post_duration); + fade_->setMode(fade_mode_); + fade_->activate(); +} + +// Inicializa el fondo +void HiScoreTable::initBackground() +{ + background_->setPos(param.game.game_area.rect); + background_->setCloudsSpeed(-0.1f); + + const int lucky = rand() % 3; + //const int lucky = 2; + switch (lucky) + { + case 0: // Fondo verde + { + background_->setGradientNumber(2); + background_->setTransition(0.0f); + background_->setSunProgression(1.0f); + background_->setMoonProgression(0.4f); + background_fade_color_ = Color(0x00, 0x79, 0x6b); + break; + } + + case 1: // Fondo naranja + { + background_->setGradientNumber(1); + background_->setTransition(0.0f); + background_->setSunProgression(0.65f); + background_->setMoonProgression(0.0f); + background_fade_color_ = Color(0xff, 0x6b, 0x97); + break; + } + + case 2: // Fondo azul + { + background_->setGradientNumber(0); + background_->setTransition(0.0f); + background_->setSunProgression(0.0f); + background_->setMoonProgression(0.0f); + background_fade_color_ = Color(0x02, 0x88, 0xd1); + break; + } + + default: + break; + } } \ No newline at end of file diff --git a/source/hiscore_table.h b/source/hiscore_table.h index 024ac4a..cd8828e 100644 --- a/source/hiscore_table.h +++ b/source/hiscore_table.h @@ -1,16 +1,18 @@ #pragma once -#include // para SDL_Rect -#include // para SDL_Renderer, SDL_Texture -#include // para Uint16, Uint32, Uint8 -#include // para unique_ptr -#include // para string -#include "sprite.h" -#include "path_sprite.h" -class Background; // lines 8-8 -class Fade; // lines 9-9 -class Text; // lines 10-10 -enum class FadeMode : Uint8; // lines 11-11 +#include // Para SDL_Rect +#include // Para SDL_Renderer, SDL_Texture +#include // Para Uint16, Uint32, Uint8 +#include // Para unique_ptr, shared_ptr +#include // Para string +#include // Para vector +#include "utils.h" +class Background; // lines 10-10 +class Fade; // lines 11-11 +class PathSprite; +class Sprite; +enum class FadeMode : Uint8; // lines 13-13 +struct Path; /* Esta clase gestiona un estado del programa. Se encarga de mostrar la tabla con las puntuaciones @@ -35,16 +37,16 @@ private: std::unique_ptr fade_; // Objeto para renderizar fades std::unique_ptr background_; // Objeto para dibujar el fondo del juego - std::shared_ptr text_; // Objeto para escribir texto std::unique_ptr header_; // Sprite con la cabecera del texto std::vector> entry_names_; // Lista con los spritres de cada uno de los nombres de la tabla de records std::vector paths_; // Vector con los recorridos precalculados // Variables - Uint16 counter_; // Contador - Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa - SDL_Rect view_area_; // Parte de la textura que se muestra en pantalla - FadeMode fade_mode_; // Modo de fade a utilizar + Uint16 counter_ = 0; // Contador + Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa + SDL_Rect view_area_; // Parte de la textura que se muestra en pantalla + FadeMode fade_mode_; // Modo de fade a utilizar + Color background_fade_color_; // Color de atenuación del fondo // Actualiza las variables void update(); @@ -76,6 +78,12 @@ private: // Actualiza las posiciones de los sprites de texto void updateSprites(); + // Inicializa el fade + void initFade(); + + // Inicializa el fondo + void initBackground(); + public: // Constructor HiScoreTable(); diff --git a/source/instructions.cpp b/source/instructions.cpp index 886420d..3c9bd51 100644 --- a/source/instructions.cpp +++ b/source/instructions.cpp @@ -159,7 +159,6 @@ void Instructions::fillTexture() text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor2, lang::getText(16), 1, orange_color, 1, shdw_txt_color); const int anchor3 = anchor2 + space_post_header; - // const int anchor4 = anchor3 + ((param.game.item_size + text->getCharacterSize()) / 2); text_->writeShadowed(anchor_item + desp_x, anchor3 + space_between_item_lines * 0, lang::getText(17), shdw_txt_color); text_->writeShadowed(anchor_item + desp_x, anchor3 + space_between_item_lines * 1, lang::getText(18), shdw_txt_color); text_->writeShadowed(anchor_item + desp_x, anchor3 + space_between_item_lines * 2, lang::getText(19), shdw_txt_color); diff --git a/source/tabe.cpp b/source/tabe.cpp index efb26ac..149d302 100644 --- a/source/tabe.cpp +++ b/source/tabe.cpp @@ -2,6 +2,7 @@ #include "tabe.h" #include // Para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE #include // Para rand, abs +#include // Para max #include "jail_audio.h" // Para JA_PlaySound #include "param.h" // Para Param, ParamGame, param #include "resource.h" // Para Resource diff --git a/source/tabe.h b/source/tabe.h index 6a93bb1..a8ed9cc 100644 --- a/source/tabe.h +++ b/source/tabe.h @@ -1,7 +1,8 @@ #pragma once -#include "animated_sprite.h" -#include +#include // Para SDL_Rect +#include // Para unique_ptr +#include "animated_sprite.h" // Para AnimatedSprite enum class TabeDirection : int { diff --git a/source/text.cpp b/source/text.cpp index 3bf499d..1a7888a 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -178,7 +178,7 @@ std::shared_ptr Text::writeDXToTexture(Uint8 flags, const std::string & { auto renderer = Screen::get()->getRenderer(); auto texture = std::make_shared(renderer); - auto width = Text::lenght(text, kerning); + auto width = Text::lenght(text, kerning) + shadow_distance; auto height = box_height_ + shadow_distance; auto temp = SDL_GetRenderTarget(renderer); texture->createBlank(width, height, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET); diff --git a/source/texture.cpp b/source/texture.cpp index c906622..20f7dd5 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -164,6 +164,10 @@ void Texture::setColor(Uint8 red, Uint8 green, Uint8 blue) { SDL_SetTextureColorMod(texture_, red, green, blue); } +void Texture::setColor(Color color) +{ + SDL_SetTextureColorMod(texture_, color.r, color.g, color.b); +} // Establece el blending void Texture::setBlendMode(SDL_BlendMode blending) diff --git a/source/texture.h b/source/texture.h index 37bfd73..16cc4e6 100644 --- a/source/texture.h +++ b/source/texture.h @@ -1,13 +1,14 @@ #pragma once -#include // para SDL_BlendMode -#include // para SDL_PIXELFORMAT_RGBA8888, SDL_PixelF... -#include // para SDL_Point, SDL_Rect -#include // para SDL_Renderer, SDL_FLIP_NONE, SDL_TEX... -#include // para Uint8, Uint32, Uint16 -#include // para string, basic_string -#include // para vector -#include +#include // Para SDL_BlendMode +#include // Para SDL_PIXELFORMAT_RGBA8888, SDL_PixelF... +#include // Para SDL_Point, SDL_Rect +#include // Para SDL_Renderer, SDL_FLIP_NONE, SDL_TEX... +#include // Para Uint8, Uint16, Uint32 +#include // Para shared_ptr +#include // Para string +#include // Para vector +struct Color; // Definiciones de tipos struct Surface @@ -65,6 +66,7 @@ public: // Establece el color para la modulacion void setColor(Uint8 red, Uint8 green, Uint8 blue); + void setColor(Color color); // Establece el blending void setBlendMode(SDL_BlendMode blending); diff --git a/source/utils.cpp b/source/utils.cpp index 23d750f..a1dbfde 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -23,6 +23,7 @@ const Color scoreboard_hard_color = Color(0x76, 0x42, 0x8A); const Color flash_color = Color(0xFF, 0xFF, 0xFF); const Color fade_color = Color(0x27, 0x27, 0x36); const Color orange_color = Color(0xFF, 0x7A, 0x00); +const Color orange_soft_color = Color(0xFF, 0xA0, 0x33); // Calcula el cuadrado de la distancia entre dos puntos double distanceSquared(int x1, int y1, int x2, int y2) diff --git a/source/utils.h b/source/utils.h index 05a8515..81961b6 100644 --- a/source/utils.h +++ b/source/utils.h @@ -44,6 +44,30 @@ struct Color Uint8 r, g, b; constexpr Color() : r(0), g(0), b(0) {} explicit constexpr Color(int red, int green, int blue) : r(red), g(green), b(blue) {} + + // Método para obtener el color inverso + constexpr Color getInverse() const + { + return Color(255 - r, 255 - g, 255 - b); + } + + // Método para aclarar el color + Color lighten(int amount = 50) const + { + return Color( + std::min(255, r + amount), + std::min(255, g + amount), + std::min(255, b + amount)); + } + + // Método para oscurecer el color + Color darken(int amount = 50) const + { + return Color( + std::max(0, r - amount), + std::max(0, g - amount), + std::max(0, b - amount)); + } }; // Posiciones de las notificaciones @@ -177,4 +201,5 @@ extern const Color scoreboard_normal_color; extern const Color scoreboard_hard_color; extern const Color flash_color; extern const Color fade_color; -extern const Color orange_color; \ No newline at end of file +extern const Color orange_color; +extern const Color orange_soft_color; \ No newline at end of file