From 0a9a92d4b7f3dc4b9f9752522817b3cc0793eac4 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Wed, 5 Feb 2025 09:45:30 +0100 Subject: [PATCH] El text de la tabla de puntuacion ja ix centrat i el "diferent" es el que fa 10 --- source/director.cpp | 2 +- source/hiscore_table.cpp | 58 +++++++++------------------------------- source/path_sprite.h | 4 +-- 3 files changed, 16 insertions(+), 48 deletions(-) diff --git a/source/director.cpp b/source/director.cpp index 27070a4..244ea93 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -52,7 +52,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::CREDITS; + section::name = section::Name::HI_SCORE_TABLE; #else // NORMAL GAME section::name = section::Name::LOGO; section::attract_mode = section::AttractMode::TITLE_TO_DEMO; diff --git a/source/hiscore_table.cpp b/source/hiscore_table.cpp index 3bf6b11..c3e70d6 100644 --- a/source/hiscore_table.cpp +++ b/source/hiscore_table.cpp @@ -266,7 +266,7 @@ void HiScoreTable::createSprites() int backbuffer_height; SDL_QueryTexture(backbuffer_, nullptr, nullptr, &backbuffer_width, &backbuffer_height); - // Hay 27 letras - 7 de puntos quedan 20 caracteres 20 - name_lenght 0 num_dots + // Hay 27 letras - 7 de puntos quedan 20 caracteres 20 - name_lenght 0 num_dots <-- Esto no se qué coño es constexpr int max_names = 10; constexpr int space_between_header = 32; const int space_between_lines = entry_text->getCharacterSize() * 2; @@ -281,9 +281,10 @@ void HiScoreTable::createSprites() const int animation = rand() % 4; for (int i = 0; i < max_names; ++i) { - const auto table_position = (i + 1 >= 10) ? format(i + 1) + ". " : " " + format(i + 1) + ". "; + // const auto table_position = (i + 1 >= 10) ? format(i + 1) + ". " : " " + format(i + 1) + ". "; + const auto table_position = format(i + 1) + ". "; const auto score = format(options.game.hi_score_table.at(i).score); - const auto num_dots = 25 - table_position.size() - options.game.hi_score_table.at(i).name.size() - score.size(); + const auto num_dots = 22 - options.game.hi_score_table.at(i).name.size() - score.size(); std::string dots; for (int j = 0; j < (int)num_dots; ++j) { @@ -292,32 +293,21 @@ void HiScoreTable::createSprites() const auto line = table_position + options.game.hi_score_table.at(i).name + dots + score; entry_names_.emplace_back(std::make_shared(entry_text->writeDXToTexture(TEXT_SHADOW, line, 1, orange_color, 1, shdw_txt_color))); + const int pos_x = (i < 9) ? (backbuffer_width - entry_names_.front()->getWidth()) / 2 : (backbuffer_width - entry_names_.front()->getWidth()) / 2 - entry_text->getCharacterSize(); + const int pos_y = (i * space_between_lines) + first_line + space_between_header; + constexpr int steps = 80; switch (animation) { case 0: // Ambos lados alternativamente { if (i % 2 == 0) { - 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()->addPath(-entry_names_.back()->getWidth(), pos_x, PathType::HORIZONTAL, pos_y, steps, easeOutQuint); entry_names_.back()->setPosition(-entry_names_.back()->getWidth(), 0); } else { - 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()->addPath(backbuffer_width, pos_x, PathType::HORIZONTAL, pos_y, steps, easeOutQuint); entry_names_.back()->setPosition(backbuffer_width, 0); } break; @@ -325,42 +315,21 @@ void HiScoreTable::createSprites() 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()->addPath(-entry_names_.back()->getWidth(), pos_x, PathType::HORIZONTAL, pos_y, steps, easeOutQuint); 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()->addPath(backbuffer_width, pos_x, PathType::HORIZONTAL, pos_y, steps, easeOutQuint); entry_names_.back()->setPosition(backbuffer_width, 0); break; } case 3: // Entran desde la parte inferior { - entry_names_.back()->addPath( - backbuffer_height, - (i * space_between_lines) + first_line + space_between_header, - PathType::VERTICAL, - (backbuffer_width - entry_names_.back()->getWidth()) / 2, - 80, - easeOutQuint, - 0); + entry_names_.back()->addPath(backbuffer_height, pos_y, PathType::VERTICAL, pos_x, steps, easeOutQuint); entry_names_.back()->setPosition(0, backbuffer_height); } @@ -410,7 +379,6 @@ void HiScoreTable::initBackground() background_->setCloudsSpeed(-0.1f); const int lucky = rand() % 3; - //const int lucky = 2; switch (lucky) { case 0: // Fondo verde @@ -418,7 +386,7 @@ void HiScoreTable::initBackground() background_->setGradientNumber(2); background_->setTransition(0.0f); background_->setSunProgression(1.0f); - background_->setMoonProgression(0.4f); + background_->setMoonProgression(0.0f); background_fade_color_ = Color(0x00, 0x79, 0x6b); break; } diff --git a/source/path_sprite.h b/source/path_sprite.h index 31fc71e..bb35b32 100644 --- a/source/path_sprite.h +++ b/source/path_sprite.h @@ -65,8 +65,8 @@ public: // Añade un recorrido void addPath(Path path, bool centered = false); - void addPath(std::vector spots, int waiting_counter); - void addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function &easingFunction, int waiting_counter); + void addPath(std::vector spots, int waiting_counter = 0); + void addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function &easingFunction, int waiting_counter = 0); // Habilita el objeto void enable();