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 <algorithm>
// Constructor
Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section)
{
// Copia los punteros
this->renderer = renderer;
@@ -10,6 +10,7 @@ Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
this->resource = resource;
this->asset = asset;
this->options = options;
this->section = section;
// Reserva memoria para los punteros a objetos
eventHandler = new SDL_Event();
@@ -21,8 +22,8 @@ Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
preCounter = 0;
postCounter = 0;
postCounterEnabled = false;
section.name = SECTION_PROG_ENDING2;
section.subsection = 0;
section->name = SECTION_PROG_ENDING2;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
distSpriteText = 8;
@@ -184,7 +185,7 @@ void Ending2::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_PROG_QUIT;
break;
}
@@ -194,7 +195,7 @@ void Ending2::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:
@@ -239,11 +240,11 @@ void Ending2::checkEventHandler()
}
// Bucle principal
section_t Ending2::run()
void Ending2::run()
{
JA_PlayMusic(music);
while (section.name == SECTION_PROG_ENDING2)
while (section->name == SECTION_PROG_ENDING2)
{
update();
render();
@@ -251,8 +252,6 @@ section_t Ending2::run()
JA_StopMusic();
JA_SetVolume(128);
return section;
}
// Actualiza los contadores
@@ -275,8 +274,8 @@ void Ending2::updateCounters()
if (postCounter > 600)
{
section.name = SECTION_PROG_LOGO;
section.subsection = SUBSECTION_LOGO_TO_INTRO;
section->name = SECTION_PROG_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO;
}
}