Cambiada la variable section por un puntero

This commit is contained in:
2022-12-16 09:32:33 +01:00
parent 2abde36a5e
commit 4d8bb46a52
22 changed files with 191 additions and 216 deletions

View File

@@ -2,7 +2,7 @@
#include <iostream>
// Constructor
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, int subsection)
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section)
{
// Copia la dirección de los objetos
this->resource = resource;
@@ -10,6 +10,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
this->screen = screen;
this->asset = asset;
this->options = options;
this->section = section;
// Reserva memoria para los punteros
eventHandler = new SDL_Event();
@@ -37,8 +38,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
// Inicializa variables
counter = 0;
section.name = SECTION_PROG_LOGO;
section.subsection = subsection;
section->name = SECTION_PROG_LOGO;
ticks = 0;
ticksSpeed = 15;
initFade = 300;
@@ -77,7 +77,7 @@ void Logo::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_PROG_QUIT;
break;
}
@@ -87,7 +87,7 @@ void Logo::checkEventHandler()
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_QUIT;
section->name = SECTION_PROG_QUIT;
break;
case SDL_SCANCODE_B:
@@ -125,7 +125,7 @@ void Logo::checkEventHandler()
break;
default:
section.subsection = SUBSECTION_LOGO_TO_TITLE;
section->subsection = SUBSECTION_LOGO_TO_TITLE;
endSection();
break;
}
@@ -175,26 +175,32 @@ void Logo::updateTextureColors()
{
texture2->setColor(color[0].r, color[0].g, color[0].b);
}
else if (counter == ini + inc * 1)
{
texture2->setColor(color[1].r, color[1].g, color[1].b);
}
else if (counter == ini + inc * 2)
{
texture2->setColor(color[2].r, color[2].g, color[2].b);
}
else if (counter == ini + inc * 3)
{
texture2->setColor(color[3].r, color[3].g, color[3].b);
}
else if (counter == ini + inc * 4)
{
texture2->setColor(color[4].r, color[4].g, color[4].b);
}
else if (counter == ini + inc * 5)
{
texture2->setColor(color[5].r, color[5].g, color[5].b);
}
else if (counter == ini + inc * 6)
{
texture2->setColor(color[6].r, color[6].g, color[6].b);
@@ -210,31 +216,37 @@ void Logo::updateTextureColors()
texture->setColor(color[6].r, color[6].g, color[6].b);
texture2->setColor(color[6].r, color[6].g, color[6].b);
}
else if (counter == initFade + inc * 1)
{
texture->setColor(color[5].r, color[5].g, color[5].b);
texture2->setColor(color[5].r, color[5].g, color[5].b);
}
else if (counter == initFade + inc * 2)
{
texture->setColor(color[4].r, color[4].g, color[4].b);
texture2->setColor(color[4].r, color[4].g, color[4].b);
}
else if (counter == initFade + inc * 3)
{
texture->setColor(color[3].r, color[3].g, color[3].b);
texture2->setColor(color[3].r, color[3].g, color[3].b);
}
else if (counter == initFade + inc * 4)
{
texture->setColor(color[2].r, color[2].g, color[2].b);
texture2->setColor(color[2].r, color[2].g, color[2].b);
}
else if (counter == initFade + inc * 5)
{
texture->setColor(color[1].r, color[1].g, color[1].b);
texture2->setColor(color[1].r, color[1].g, color[1].b);
}
else if (counter == initFade + inc * 6)
{
texture->setColor(color[0].r, color[0].g, color[0].b);
@@ -295,18 +307,16 @@ void Logo::render()
}
// Bucle para el logo del juego
section_t Logo::run()
void Logo::run()
{
// Detiene la música
JA_StopMusic();
while (section.name == SECTION_PROG_LOGO)
while (section->name == SECTION_PROG_LOGO)
{
update();
render();
}
return section;
}
// Cambia la paleta
@@ -318,5 +328,5 @@ void Logo::switchPalette()
// Termina la sección
void Logo::endSection()
{
section.name = SECTION_PROG_ENTER_ID;
section->name = SECTION_PROG_ENTER_ID;
}