JA VA! Nomes s'havia de fer les coses be i no ser un ansias

This commit is contained in:
2025-02-22 00:30:32 +01:00
parent f6098a479b
commit e361d295c1
39 changed files with 1053 additions and 1098 deletions

View File

@@ -13,9 +13,10 @@
#include "text.h" // for Text
#include "texture.h" // for Texture
#include "utils.h" // for color_t, stringToColor, options_t
#include "options.h"
// Constructor
Ending2::Ending2(Resource *resource, options_t *options, section_t *section)
Ending2::Ending2(Resource *resource)
{
// Copia los punteros
this->screen = Screen::get();
@@ -23,8 +24,6 @@ Ending2::Ending2(Resource *resource, options_t *options, section_t *section)
this->resource = resource;
this->asset = Asset::get();
this->input = Input::get();
this->options = options;
this->section = section;
// Reserva memoria para los punteros a objetos
eventHandler = new SDL_Event();
@@ -36,8 +35,8 @@ Ending2::Ending2(Resource *resource, options_t *options, section_t *section)
preCounter = 0;
postCounter = 0;
postCounterEnabled = false;
section->name = SECTION_ENDING2;
section->subsection = 0;
options.section.name = SECTION_ENDING2;
options.section.subsection = 0;
ticks = 0;
ticksSpeed = 15;
distSpriteText = 8;
@@ -50,11 +49,11 @@ Ending2::Ending2(Resource *resource, options_t *options, section_t *section)
const std::vector<std::string> colorList = {"white", "yellow", "cyan", "green", "magenta", "red", "blue", "black"};
for (auto cl : colorList)
{
colors.push_back(stringToColor(options->palette, cl));
colors.push_back(stringToColor(options.palette, cl));
}
// Cambia el color del borde
screen->setBorderColor(stringToColor(options->palette, "black"));
screen->setBorderColor(stringToColor(options.palette, "black"));
// Inicializa la lista de sprites
iniSpriteList();
@@ -130,7 +129,7 @@ void Ending2::render()
screen->start();
// Limpia la pantalla
screen->clean(stringToColor(options->palette, "black"));
screen->clean(stringToColor(options.palette, "black"));
// Dibuja los sprites
renderSprites();
@@ -199,7 +198,7 @@ void Ending2::checkEvents()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section->name = SECTION_QUIT;
options.section.name = SECTION_QUIT;
break;
}
}
@@ -211,8 +210,8 @@ void Ending2::checkInput()
if (input->checkInput(input_exit, REPEAT_FALSE))
{
section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO;
options.section.name = SECTION_LOGO;
options.section.subsection = SUBSECTION_LOGO_TO_INTRO;
}
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
@@ -246,7 +245,7 @@ void Ending2::run()
{
JA_PlayMusic(music);
while (section->name == SECTION_ENDING2)
while (options.section.name == SECTION_ENDING2)
{
update();
checkEvents();
@@ -277,8 +276,8 @@ void Ending2::updateCounters()
if (postCounter > 600)
{
section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO;
options.section.name = SECTION_LOGO;
options.section.subsection = SUBSECTION_LOGO_TO_INTRO;
}
}
@@ -416,7 +415,7 @@ void Ending2::updateTexts()
// Dibuja los sprites
void Ending2::renderSprites()
{
const color_t color = stringToColor(options->palette, "red");
const color_t color = stringToColor(options.palette, "red");
for (auto sprite : sprites)
{
const bool a = sprite->getRect().y + sprite->getRect().h > 0;
@@ -429,7 +428,7 @@ void Ending2::renderSprites()
}
// Pinta el ultimo elemento de otro color
const color_t c = stringToColor(options->palette, "white");
const color_t c = stringToColor(options.palette, "white");
sprites.back()->getTexture()->setColor(c.r, c.g, c.b);
sprites.back()->render();
}
@@ -437,7 +436,7 @@ void Ending2::renderSprites()
// Dibuja los sprites con el texto
void Ending2::renderSpriteTexts()
{
const color_t color = stringToColor(options->palette, "white");
const color_t color = stringToColor(options.palette, "white");
for (auto sprite : spriteTexts)
{
const bool a = sprite->getRect().y + sprite->getRect().h > 0;
@@ -644,5 +643,5 @@ void Ending2::updateMusicVolume()
// Cambia la paleta
void Ending2::switchPalette()
{
options->palette = (options->palette == p_zxspectrum) ? p_zxarne : p_zxspectrum;
options.palette = (options.palette == p_zxspectrum) ? p_zxarne : p_zxspectrum;
}