Treballant en scoreboard::fillPanelTextures

This commit is contained in:
2025-02-06 20:58:15 +01:00
parent 44e4ca490d
commit 559210652f
11 changed files with 194 additions and 134 deletions

View File

@@ -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::LOGO;
section::name = section::Name::GAME;
#else // NORMAL GAME
section::name = section::Name::LOGO;
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;

View File

@@ -1,37 +1,42 @@
#include "enter_name.h"
#include "utils.h"
#include <stddef.h> // Para size_t
#include <algorithm> // Para max, min
// Constructor
EnterName::EnterName()
{
init();
}
: character_list_(" ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-+-*/=?¿<>!\"#$%&/()") {}
// Inicializa el objeto
void EnterName::init()
void EnterName::init(const std::string &name)
{
// Obtiene el puntero al nombre
name_ = "A";
// No se pasa ningún nombre
if (name == "")
{
name_ = "A";
position_ = 0;
}
// Se pasa un nombre
else
{
name_ = name;
position_ = name_.length();
}
// Inicia la lista de caracteres permitidos
character_list_ = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-+-*/=?¿<>!\"#$%&/()";
position_ = 0;
num_characters_ = static_cast<int>(character_list_.size());
// Pone la lista de indices para que refleje el nombre
updateCharacterIndex();
// Actualiza el nombre para que ocupe todos los espacios
updateName();
// Inicializa el vector de indices con el nombre y espacios
initCharacterIndex(name_);
}
// Incrementa la posición
void EnterName::incPosition()
{
position_++;
position_ = std::min(position_, NAME_LENGHT);
checkIfPositionHasBeenUsed();
++position_;
position_ = std::min(position_, NAME_LENGHT + 1);
if (position_ <= NAME_LENGHT)
{
character_index_[position_] = character_index_[position_ - 1];
}
updateNameFromCharacterIndex();
}
// Decrementa la posición
@@ -39,17 +44,19 @@ void EnterName::decPosition()
{
--position_;
position_ = std::max(position_, 0);
character_index_[position_ + 1] = 0;
updateNameFromCharacterIndex();
}
// Incrementa el índice
void EnterName::incIndex()
{
++character_index_[position_];
if (character_index_[position_] >= num_characters_)
if (character_index_[position_] >= character_list_.size())
{
character_index_[position_] = 0;
}
updateName();
updateNameFromCharacterIndex();
}
// Decrementa el índice
@@ -58,36 +65,35 @@ void EnterName::decIndex()
--character_index_[position_];
if (character_index_[position_] < 0)
{
character_index_[position_] = num_characters_ - 1;
character_index_[position_] = character_list_.size() - 1;
}
updateName();
updateNameFromCharacterIndex();
}
// Actualiza el nombre a partir de la lista de índices
void EnterName::updateName()
void EnterName::updateNameFromCharacterIndex()
{
name_.clear();
for (int i = 0; i < NAME_LENGHT; ++i)
{
name_.push_back(character_list_[character_index_[i]]);
}
name_ = trim(name_);
}
// Actualiza la variable
void EnterName::updateCharacterIndex()
void EnterName::initCharacterIndex(const std::string &name)
{
// Rellena de espacios y marca como no usados
// Rellena de espacios
for (size_t i = 0; i < NAME_LENGHT; ++i)
{
character_index_[i] = 0;
position_has_been_used_[i] = false;
}
// Coloca los índices en función de los caracteres que forman el nombre
for (size_t i = 0; i < name_.size(); ++i)
for (size_t i = 0; i < name.substr(0, NAME_LENGHT).size(); ++i)
{
character_index_[i] = findIndex(name_.at(i));
position_has_been_used_[i] = true;
character_index_[i] = findIndex(name.at(i));
}
}
@@ -99,29 +105,3 @@ int EnterName::findIndex(char character) const
return i;
return 0;
}
// Obtiene el nombre
std::string EnterName::getName() const
{
return name_;
}
// Obtiene la posición que se está editando
int EnterName::getPosition() const
{
return position_;
}
// Comprueba la posición y copia el caracter si es necesario
void EnterName::checkIfPositionHasBeenUsed()
{
auto used = position_has_been_used_[position_];
if (!used && position_ > 0)
{
character_index_[position_] = character_index_[position_ - 1];
}
position_has_been_used_[position_] = true;
updateName();
}

View File

@@ -1,6 +1,7 @@
#pragma once
#include <string>
#include "utils.h"
constexpr int NAME_LENGHT = 6;
@@ -16,25 +17,20 @@ constexpr int NAME_LENGHT = 6;
class EnterName
{
private:
std::string character_list_; // Lista de todos los caracteres permitidos
std::string name_; // Nombre introducido
int position_; // Posición a editar del nombre
int num_characters_; // Cantidad de caracteres de la lista de caracteres
int character_index_[NAME_LENGHT]; // Indice de la lista para cada uno de los caracteres que forman el nombre
bool position_has_been_used_[NAME_LENGHT]; // Indica si en esa posición se ha puesto ya alguna letra. Se utiliza para replicar la letra anterior la primera vez
std::string character_list_; // Lista de todos los caracteres permitidos
std::string name_; // Nombre introducido
int position_; // Posición a editar del nombre
size_t character_index_[NAME_LENGHT]; // Indice de la lista para cada uno de los caracteres que forman el nombre
// Actualiza el nombre a partir de la lista de índices
void updateName();
void updateNameFromCharacterIndex();
// Actualiza la variable
void updateCharacterIndex();
void initCharacterIndex(const std::string &name);
// Encuentra el indice de un caracter en "characterList"
int findIndex(char character) const;
// Comprueba la posición y copia el caracter si es necesario
void checkIfPositionHasBeenUsed();
public:
// Constructor
EnterName();
@@ -43,7 +39,7 @@ public:
~EnterName() = default;
// Inicializa el objeto
void init();
void init(const std::string &name = "");
// Incrementa la posición
void incPosition();
@@ -57,9 +53,8 @@ public:
// Decrementa el índice
void decIndex();
// Obtiene el nombre
std::string getName() const;
// Obtiene la posición que se está editando
int getPosition() const;
// Getters
std::string getFinalName() const { return trim(name_.substr(0, position_)); }
std::string getCurrentName() const { return trim(name_); }
int getPosition() const { return position_; }
};

View File

@@ -1650,17 +1650,7 @@ void Game::handleNameInput(const std::shared_ptr<Player> &player)
input_->checkInput(InputType::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) ||
input_->checkInput(InputType::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
{
if (player->getRecordNamePos() == NAME_LENGHT - 1)
{
player->setInput(InputType::START);
addScoreToScoreBoard(player);
const auto state = player->getPlayingState();
player->setPlayingState(state == PlayerState::ENTERING_NAME ? PlayerState::CONTINUE : PlayerState::LEAVING_SCREEN);
}
else
{
player->setInput(InputType::RIGHT);
}
player->setInput(InputType::RIGHT);
}
else if (input_->checkInput(InputType::UP, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
{
@@ -1678,8 +1668,7 @@ void Game::handleNameInput(const std::shared_ptr<Player> &player)
{
player->setInput(InputType::START);
addScoreToScoreBoard(player);
const auto state = player->getPlayingState();
player->setPlayingState(state == PlayerState::ENTERING_NAME ? PlayerState::CONTINUE : PlayerState::LEAVING_SCREEN);
player->setPlayingState(PlayerState::SHOWING_NAME);
}
}

View File

@@ -395,7 +395,7 @@ void HiScoreTable::initBackground()
background_->setTransition(0.0f);
background_->setSunProgression(1.0f);
background_->setMoonProgression(0.0f);
background_fade_color_ = Color(0x00, 0x79, 0x6b);
background_fade_color_ = green_sky_color;
break;
}
@@ -405,7 +405,7 @@ void HiScoreTable::initBackground()
background_->setTransition(0.0f);
background_->setSunProgression(0.65f);
background_->setMoonProgression(0.0f);
background_fade_color_ = Color(0xff, 0x6b, 0x97);
background_fade_color_ = pink_sky_color;
break;
}
@@ -415,7 +415,7 @@ void HiScoreTable::initBackground()
background_->setTransition(0.0f);
background_->setSunProgression(0.0f);
background_->setMoonProgression(0.0f);
background_fade_color_ = Color(0x02, 0x88, 0xd1);
background_fade_color_ = blue_sky_color;
break;
}
@@ -427,10 +427,10 @@ void HiScoreTable::initBackground()
// Obtiene un color del vector de colores de entradas
Color HiScoreTable::getEntryColor(int counter_)
{
int cycle_length = entry_colors_.size() * 2 - 2; // Esto es 6 en este caso
int n = counter_ % cycle_length;
int cycle_length = entry_colors_.size() * 2 - 2;
size_t n = counter_ % cycle_length;
int index;
size_t index;
if (n < entry_colors_.size())
{
index = n; // Avanza: 0,1,2,3

View File

@@ -58,7 +58,7 @@ void Player::init()
score_ = 0;
score_multiplier_ = 1.0f;
cool_down_ = 10;
enter_name_->init();
enter_name_->init(last_enter_name_);
// Establece la posición del sprite
player_sprite_->clear();
@@ -148,6 +148,7 @@ void Player::setInputEnteringName(InputType input)
enter_name_->decIndex();
break;
case InputType::START:
last_enter_name_ = getRecordName();
break;
default:
break;
@@ -449,6 +450,7 @@ void Player::update()
updateInvulnerable();
updateContinueCounter();
updateEnterNameCounter();
updateShowingName();
updateScoreboard();
}
@@ -474,7 +476,7 @@ void Player::updateScoreboard()
case PlayerState::ENTERING_NAME:
case PlayerState::ENTERING_NAME_GAME_COMPLETED:
{
Scoreboard::get()->setRecordName(getScoreBoardPanel(), enter_name_->getName());
Scoreboard::get()->setRecordName(getScoreBoardPanel(), enter_name_->getCurrentName());
Scoreboard::get()->setSelectorPos(getScoreBoardPanel(), getRecordNamePos());
break;
}
@@ -525,6 +527,13 @@ void Player::setPlayingState(PlayerState state)
setScoreboardMode(ScoreboardMode::ENTER_NAME);
break;
}
case PlayerState::SHOWING_NAME:
{
showing_name_ticks_ = SDL_GetTicks();
setScoreboardMode(ScoreboardMode::SHOW_NAME);
Scoreboard::get()->setRecordName(scoreboard_panel_, last_enter_name_);
break;
}
case PlayerState::DYING:
{
// Activa la animación de morir
@@ -712,6 +721,19 @@ void Player::updateEnterNameCounter()
}
}
// Actualiza el estado de SHOWING_NAME
void Player::updateShowingName()
{
if (playing_state_ == PlayerState::SHOWING_NAME)
{
constexpr int TICKS_SPEED = 5000;
if (SDL_GetTicks() - enter_name_ticks_ > TICKS_SPEED)
{
game_completed_ ? setPlayingState(PlayerState::LEAVING_SCREEN) : setPlayingState(PlayerState::CONTINUE);
}
}
}
// Decrementa el contador de continuar
void Player::decContinueCounter()
{

View File

@@ -34,6 +34,7 @@ enum class PlayerState
CONTINUE, // Está con la cuenta atras para continuar
WAITING, // No está jugando pero puede entrar a jugar
ENTERING_NAME, // Introduciendo nombre
SHOWING_NAME, // Mostrando el nombre introducido
DYING, // El cadaver está volando por ahi
DIED, // El cadaver ha desaparecido por el fondo
GAME_OVER, // No está jugando y no puede entrar a jugar
@@ -92,9 +93,11 @@ private:
bool demo_; // Para que el jugador sepa si está en el modo demostración
int enter_name_counter_; // Contador para poner nombre
Uint32 enter_name_ticks_ = 0; // Variable para poder cambiar el contador de poner nombre en función del tiempo
Uint32 showing_name_ticks_ = 0; // Tiempo en el que se entra al estado SHOWING_NAME
int step_counter_ = 0; // Cuenta los pasos para los estados en los que camina automáticamente
bool game_completed_ = false; // Indica si ha completado el juego
int credits_used_ = 1; // Indica el numero de veces que ha continuado
std::string last_enter_name_; // Ultimo nombre introducido en la tabla de puntuaciones
// Actualiza el circulo de colisión a la posición del jugador
void shiftColliders();
@@ -111,6 +114,9 @@ private:
// Actualiza el contador de entrar nombre
void updateEnterNameCounter();
// Actualiza el estado de SHOWING_NAME
void updateShowingName();
// Decrementa el contador de entrar nombre
void decEnterNameCounter();
@@ -226,7 +232,7 @@ public:
int getPosX() const { return static_cast<int>(pos_x_); }
int getPosY() const { return pos_y_; }
int getPowerUpCounter() const { return power_up_counter_; }
std::string getRecordName() const { return enter_name_->getName().substr(0, getRecordNamePos()); }
std::string getRecordName() const { return enter_name_->getFinalName(); }
int getScore() const { return score_; }
int getScoreBoardPanel() const { return scoreboard_panel_; }
int getWidth() const { return WIDTH_; }

View File

@@ -10,7 +10,7 @@
#include "screen.h" // Para Screen
#include "sprite.h" // Para Sprite
#include "text.h" // Para Text
#include "enter_name.h"
#include "enter_name.h" // Para NAME_LENGHT
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Scoreboard *Scoreboard::scoreboard_ = nullptr;
@@ -68,6 +68,9 @@ Scoreboard::Scoreboard()
// Rellena la textura de fondo
fillBackgroundTexture();
// Inicializa el vector de colores para el nombre
iniNameColors();
}
Scoreboard::~Scoreboard()
@@ -95,14 +98,14 @@ std::string Scoreboard::updateScoreText(int num)
}
// Actualiza el contador
void Scoreboard::updateCounter()
void Scoreboard::updateTimeCounter()
{
constexpr int TICKS_SPEED = 100;
if (SDL_GetTicks() - ticks_ > TICKS_SPEED)
{
ticks_ = SDL_GetTicks();
counter_++;
++time_counter_;
}
}
@@ -110,7 +113,8 @@ void Scoreboard::updateCounter()
void Scoreboard::update()
{
fillBackgroundTexture();
updateCounter();
updateTimeCounter();
++loop_counter_;
}
// Pinta el marcador
@@ -180,7 +184,7 @@ void Scoreboard::fillPanelTextures()
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText(101));
// PRESS START TO PLAY
if (counter_ % 10 < 8)
if (time_counter_ % 10 < 8)
{
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText(103));
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, lang::getText(104));
@@ -194,7 +198,7 @@ void Scoreboard::fillPanelTextures()
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText(102));
// PRESS START TO PLAY
if (counter_ % 10 < 8)
if (time_counter_ % 10 < 8)
{
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText(103));
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, lang::getText(104));
@@ -208,7 +212,7 @@ void Scoreboard::fillPanelTextures()
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText(102));
// PLEASE WAIT
if (counter_ % 10 < 8)
if (time_counter_ % 10 < 8)
{
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText(114));
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, lang::getText(115));
@@ -257,13 +261,13 @@ void Scoreboard::fillPanelTextures()
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(106));
SDL_Rect rect = {enter_name_pos_.x, enter_name_pos_.y, 5, 7};
// Recorre el nombre
for (size_t j = 0; j < record_name_[i].size(); ++j)
// Recorre todos los slots de letras del nombre
for (size_t j = 0; j < NAME_LENGHT; ++j)
{
// Selecciona el color
const Color color = j < selector_pos_[i] ? orange_soft_color.lighten() : Color(0xFF, 0xFF, 0xEB);
if (j != selector_pos_[i] || counter_ % 3 == 0)
if (j != selector_pos_[i] || time_counter_ % 3 == 0)
{
// Dibuja la linea
if (j >= selector_pos_[i])
@@ -273,20 +277,34 @@ void Scoreboard::fillPanelTextures()
}
// Dibuja la letra
text_scoreboard_->writeColored(rect.x, rect.y, record_name_[i].substr(j, 1), color);
if (j < record_name_->size())
{
text_scoreboard_->writeColored(rect.x, rect.y, record_name_[i].substr(j, 1), color);
}
}
rect.x += 7;
}
}
break;
}
case ScoreboardMode::SHOW_NAME:
{
// SCORE
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y, name_[i]);
text_scoreboard_->writeCentered(slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]));
// NAME
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(106));
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, record_name_[i], 1, getColorLikeKnightRider(name_colors_, loop_counter_ / 5));
break;
}
case ScoreboardMode::GAME_COMPLETED:
{
// GAME OVER
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, lang::getText(102));
// SCORE
if (counter_ % 10 < 8)
if (time_counter_ % 10 < 8)
{
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, lang::getText(120));
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, updateScoreText(score_[i]));
@@ -295,6 +313,9 @@ void Scoreboard::fillPanelTextures()
default:
break;
}
SDL_SetRenderDrawColor(renderer_, 255, 0, 0, 255);
SDL_RenderDrawLine(renderer_, (float)rect_.w / (float)SCOREBOARD_MAX_PANELS / 2, 0, (float)rect_.w / (float)SCOREBOARD_MAX_PANELS / 2, rect_.h);
}
// Deja el renderizador apuntando donde estaba
@@ -332,27 +353,27 @@ void Scoreboard::fillBackgroundTexture()
void Scoreboard::recalculateAnchors()
{
// Recalcula la posición y el tamaño de los paneles
const float panelWidth = (float)rect_.w / (float)SCOREBOARD_MAX_PANELS;
const float panel_width = (float)rect_.w / (float)SCOREBOARD_MAX_PANELS;
for (int i = 0; i < SCOREBOARD_MAX_PANELS; ++i)
{
panel_[i].pos.x = roundf(panelWidth * i);
panel_[i].pos.x = roundf(panel_width * i);
panel_[i].pos.y = 0;
panel_[i].pos.w = roundf(panelWidth * (i + 1)) - panel_[i].pos.x;
panel_[i].pos.w = roundf(panel_width * (i + 1)) - panel_[i].pos.x;
panel_[i].pos.h = rect_.h;
}
// Constantes para definir las zonas del panel_: 4 filas y 1 columna
const int rowSize = rect_.h / 4;
const int textHeight = 7;
const int row_size = rect_.h / 4;
const int text_height = 7;
// Filas
const int row1 = (rowSize * 0) + (textHeight / 2);
const int row2 = (rowSize * 1) + (textHeight / 2) - 1;
const int row3 = (rowSize * 2) + (textHeight / 2) - 2;
const int row4 = (rowSize * 3) + (textHeight / 2) - 3;
const int row1 = (row_size * 0) + (text_height / 2);
const int row2 = (row_size * 1) + (text_height / 2) - 1;
const int row3 = (row_size * 2) + (text_height / 2) - 2;
const int row4 = (row_size * 3) + (text_height / 2) - 3;
// Columna
const int col = panelWidth / 2;
const int col = panel_width / 2;
// Slots de 4
slot4_1_ = {col, row1};
@@ -361,8 +382,9 @@ void Scoreboard::recalculateAnchors()
slot4_4_ = {col, row4};
// Primer cuadrado para poner el nombre de record
const int enterNameLenght = NAME_LENGHT * 7;
enter_name_pos_.x = (panelWidth - enterNameLenght) / 2;
// const int enter_name_lenght = NAME_LENGHT * 7;
const int enter_name_lenght = text_scoreboard_->lenght(std::string(NAME_LENGHT, ' '));
enter_name_pos_.x = (panel_width - enter_name_lenght) / 2;
enter_name_pos_.y = row4;
// Recoloca los sprites
@@ -416,3 +438,13 @@ void Scoreboard::renderSeparator()
SDL_SetRenderDrawColor(renderer_, separator_color.r, separator_color.g, separator_color.b, 255);
SDL_RenderDrawLine(renderer_, 0, 0, rect_.w, 0);
}
// Inicializa el vector de colores para el nombre
void Scoreboard::iniNameColors()
{
name_colors_.clear();
name_colors_.emplace_back(green_color.lighten(50));
name_colors_.emplace_back(green_color.lighten(25));
name_colors_.emplace_back(green_color);
name_colors_.emplace_back(green_color.darken(25));
}

View File

@@ -29,6 +29,7 @@ enum class ScoreboardMode : int
GAME_OVER,
DEMO,
ENTER_NAME,
SHOW_NAME,
GAME_COMPLETED,
NUM_MODES,
};
@@ -72,7 +73,9 @@ private:
Color color_ = Color(); // Color del marcador
SDL_Rect rect_ = {0, 0, 320, 40}; // Posición y dimensiones del marcador
Uint32 ticks_ = SDL_GetTicks(); // Variable donde almacenar el valor de SDL_GetTiks()
int counter_ = 0; // Contador
int time_counter_ = 0; // Contador de segundos
int loop_counter_ = 0; // Contador de bucle
std::vector<Color> name_colors_; // Colores para destacar el nombre una vez introducido
// Puntos predefinidos para colocar elementos en los paneles
SDL_Point slot4_1_, slot4_2_, slot4_3_, slot4_4_;
@@ -97,11 +100,14 @@ private:
void fillBackgroundTexture();
// Actualiza el contador
void updateCounter();
void updateTimeCounter();
// Dibuja la linea que separa la zona de juego del marcador
void renderSeparator();
// Inicializa el vector de colores para el nombre
void iniNameColors();
// [SINGLETON] Ahora el constructor y el destructor son privados
// Constructor

View File

@@ -13,17 +13,40 @@
Overrides overrides = Overrides();
// Colores
const Color bg_color = Color(0x27, 0x27, 0x36);
const Color no_color = Color(0xFF, 0xFF, 0xFF);
const Color shdw_txt_color = Color(0x43, 0x43, 0x4F);
const Color separator_color = Color(0x0D, 0x1A, 0x2B);
const Color scoreboard_easy_color = Color(0x4B, 0x69, 0x2F);
const Color scoreboard_normal_color = Color(0x2E, 0x3F, 0x47);
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);
const Color bg_color = Color(0X27, 0X27, 0X36);
const Color no_color = Color(0XFF, 0XFF, 0XFF);
const Color shdw_txt_color = Color(0X43, 0X43, 0X4F);
const Color separator_color = Color(0X0D, 0X1A, 0X2B);
const Color scoreboard_easy_color = Color(0X4B, 0X69, 0X2F);
const Color scoreboard_normal_color = Color(0X2E, 0X3F, 0X47);
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);
const Color green_color = Color(0X5B, 0XEC, 0X95);
const Color blue_sky_color = Color(0X02, 0X88, 0XD1);
const Color pink_sky_color = Color(0XFF, 0X6B, 0X97);
const Color green_sky_color = Color(0X00, 0X79, 0X6B);
// Obtiene un color del vector de colores imitando al Coche Fantástico
Color getColorLikeKnightRider(const std::vector<Color> &colors, int counter_)
{
int cycle_length = colors.size() * 2 - 2;
size_t n = counter_ % cycle_length;
size_t index;
if (n < colors.size())
{
index = n; // Avanza: 0,1,2,3
}
else
{
index = 2 * (colors.size() - 1) - n; // Retrocede: 2,1
}
return colors[index];
}
// Calcula el cuadrado de la distancia entre dos puntos
double distanceSquared(int x1, int y1, int x2, int y2)

View File

@@ -124,6 +124,9 @@ struct Zone
int third_quarter_y; // Anclaje al 75% del eje X
};
// Obtiene un color del vector de colores imitando al Coche Fantástico
Color getColorLikeKnightRider(const std::vector<Color> &colors, int counter_);
// Calcula el cuadrado de la distancia entre dos puntos
double distanceSquared(int x1, int y1, int x2, int y2);
@@ -204,3 +207,7 @@ extern const Color flash_color;
extern const Color fade_color;
extern const Color orange_color;
extern const Color orange_soft_color;
extern const Color green_color;
extern const Color blue_sky_color;
extern const Color pink_sky_color;
extern const Color green_sky_color;