Arreglos en la estructura i format del codi

This commit is contained in:
2025-03-01 17:01:50 +01:00
parent 3562b139c3
commit 31cded15cc
35 changed files with 496 additions and 755 deletions

View File

@@ -90,21 +90,24 @@ void Credits::checkInput()
// Inicializa los textos
void Credits::iniTexts()
{
#ifndef GAME_CONSOLE
std::string keys = "";
if (options.keys == ControlScheme::CURSOR)
switch (options.keys)
{
case ControlScheme::CURSOR:
keys = "CURSORS";
}
else if (options.keys == ControlScheme::OPQA)
{
break;
case ControlScheme::OPQA:
keys = "O,P AND Q";
}
else
{
break;
case ControlScheme::WASD:
keys = "A,D AND W";
break;
default:
break;
}
#ifndef GAME_CONSOLE
texts_.clear();
texts_.push_back({"", stringToColor(options.video.palette, "white")});
texts_.push_back({"INSTRUCTIONS:", stringToColor(options.video.palette, "yellow")});
@@ -173,37 +176,37 @@ void Credits::fillTexture()
// Rellena la textura de texto
SDL_SetRenderTarget(renderer_, text_texture_);
Color c = stringToColor(options.video.palette, "black");
SDL_SetRenderDrawColor(renderer_, c.r, c.g, c.b, 0xFF);
Color color = stringToColor(options.video.palette, "black");
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 0xFF);
SDL_RenderClear(renderer_);
// Escribe el texto en la textura
const int size = text_->getCharacterSize();
int i = 0;
const int SIZE = text_->getCharacterSize();
int pos_y = 0;
for (auto t : texts_)
for (const auto &t : texts_)
{
text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, i * size, t.label, 1, t.color);
i++;
text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, pos_y * SIZE, t.label, 1, t.color);
pos_y++;
}
// Escribe el corazón
const int textLenght = text_->lenght(texts_[22].label, 1) - text_->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
const int posX = ((PLAY_AREA_WIDTH - textLenght) / 2) + textLenght;
text_->writeColored(posX, 176, "}", stringToColor(options.video.palette, "bright_red"));
const int TEXT_LENGHT = text_->lenght(texts_[22].label, 1) - text_->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
const int POS_X = ((PLAY_AREA_WIDTH - TEXT_LENGHT) / 2) + TEXT_LENGHT;
text_->writeColored(POS_X, 176, "}", stringToColor(options.video.palette, "bright_red"));
// Recoloca el sprite del brillo
sprite_->setPosX(posX + 2);
sprite_->setPosX(POS_X + 2);
SDL_SetRenderTarget(renderer_, nullptr);
// Rellena la textura que cubre el texto con color transparente
SDL_SetRenderTarget(renderer_, cover_texture_);
SDL_SetRenderDrawColor(renderer_, c.r, c.g, c.b, 0x00);
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 0x00);
SDL_RenderClear(renderer_);
// Los primeros 8 pixels crea una malla
SDL_SetRenderDrawColor(renderer_, c.r, c.g, c.b, 0xFF);
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 0xFF);
for (int i = 0; i < 256; i += 2)
{
SDL_RenderDrawPoint(renderer_, i, 0);
@@ -313,11 +316,4 @@ void Credits::run()
checkEvents();
render();
}
}
// Cambia la paleta
void Credits::switchPalette()
{
options.video.palette = options.video.palette == Palette::ZXSPECTRUM ? Palette::ZXARNE : Palette::ZXSPECTRUM;
fillTexture();
}