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

@@ -1,7 +1,7 @@
#include "ending.h"
// Constructor
Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section)
{
// Copia los punteros
this->renderer = renderer;
@@ -9,6 +9,7 @@ Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset
this->resource = resource;
this->asset = asset;
this->options = options;
this->section = section;
// Reserva memoria para los punteros a objetos
eventHandler = new SDL_Event();
@@ -19,8 +20,8 @@ Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset
counter = -1;
preCounter = 0;
coverCounter = 0;
section.name = SECTION_PROG_ENDING;
section.subsection = 0;
section->name = SECTION_PROG_ENDING;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
scene = 0;
@@ -150,7 +151,7 @@ void Ending::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_PROG_QUIT;
break;
}
@@ -160,7 +161,7 @@ void Ending::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:
@@ -482,11 +483,11 @@ void Ending::iniScenes()
}
// Bucle principal
section_t Ending::run()
void Ending::run()
{
JA_PlayMusic(music);
while (section.name == SECTION_PROG_ENDING)
while (section->name == SECTION_PROG_ENDING)
{
update();
render();
@@ -494,8 +495,6 @@ section_t Ending::run()
JA_StopMusic();
JA_SetVolume(128);
return section;
}
// Actualiza los contadores
@@ -571,7 +570,7 @@ void Ending::checkChangeScene()
if (scene == 5)
{
// Termina el bucle
section.name = SECTION_PROG_ENDING2;
section->name = SECTION_PROG_ENDING2;
// Mantiene los valores anteriores
scene = 4;