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 "title.h"
// Constructor
Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
Title::Title(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;
@@ -9,6 +9,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
this->screen = screen;
this->asset = asset;
this->options = options;
this->section = section;
// Reserva memoria para los punteros
eventHandler = new SDL_Event();
@@ -25,8 +26,8 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
// Inicializa variables
counter = 0;
section.name = SECTION_PROG_TITLE;
section.subsection = 0;
section->name = SECTION_PROG_TITLE;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO: P.A.C.O. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?";
@@ -79,7 +80,7 @@ void Title::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_PROG_QUIT;
break;
}
@@ -88,19 +89,19 @@ void Title::checkEventHandler()
{
if (eventHandler->type == SDL_JOYBUTTONDOWN)
{
section.name = SECTION_PROG_GAME;
section.subsection = 0;
section->name = SECTION_PROG_GAME;
section->subsection = 0;
}
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_QUIT;
section->name = SECTION_PROG_QUIT;
break;
case SDL_SCANCODE_RETURN:
section.name = SECTION_PROG_GAME;
section.subsection = 0;
section->name = SECTION_PROG_GAME;
section->subsection = 0;
break;
case SDL_SCANCODE_B:
@@ -210,8 +211,8 @@ void Title::update()
// Comprueba si ha terminado la marquesina y acaba con el titulo
if (letters[letters.size() - 1].x < -10)
{
section.name = SECTION_PROG_CREDITS;
section.subsection = 0;
section->name = SECTION_PROG_CREDITS;
section->subsection = 0;
}
}
}
@@ -239,15 +240,13 @@ void Title::render()
}
// Bucle para el logo del juego
section_t Title::run()
void Title::run()
{
while (section.name == SECTION_PROG_TITLE)
while (section->name == SECTION_PROG_TITLE)
{
update();
render();
}
return section;
}
// Recarga las texturas