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 "demo.h"
// Constructor
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Debug *debug)
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section, Debug *debug)
{
// Inicia algunas variables
board.iniClock = SDL_GetTicks();
@@ -24,6 +24,7 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
this->screen = screen;
this->debug = debug;
this->options = options;
this->section = section;
// Crea los objetos
itemTracker = new ItemTracker();
@@ -44,8 +45,8 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
board.music = true;
setScoreBoardColor();
section.name = SECTION_PROG_DEMO;
section.subsection = 0;
section->name = SECTION_PROG_DEMO;
section->subsection = 0;
}
Demo::~Demo()
@@ -67,7 +68,7 @@ void Demo::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_PROG_QUIT;
screen->setBorderColor(stringToColor(options->palette, "black"));
break;
}
@@ -78,7 +79,7 @@ void Demo::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:
@@ -116,8 +117,8 @@ void Demo::checkEventHandler()
break;
default:
section.name = SECTION_PROG_TITLE;
section.subsection = 0;
section->name = SECTION_PROG_TITLE;
section->subsection = 0;
break;
}
}
@@ -125,15 +126,13 @@ void Demo::checkEventHandler()
}
// Bucle para el juego
section_t Demo::run()
void Demo::run()
{
while (section.name == SECTION_PROG_DEMO)
while (section->name == SECTION_PROG_DEMO)
{
update();
render();
}
return section;
}
// Actualiza el juego, las variables, comprueba la entrada, etc.
@@ -255,8 +254,8 @@ void Demo::checkRoomChange()
roomIndex++;
if (roomIndex == (int)rooms.size())
{
section.name = SECTION_PROG_LOGO;
section.subsection = SUBSECTION_LOGO_TO_TITLE;
section->name = SECTION_PROG_LOGO;
section->subsection = SUBSECTION_LOGO_TO_TITLE;
}
else
{