La sección del programa se controla ahora mediante un puntero a una variable
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "intro.h"
|
||||
|
||||
// Constructor
|
||||
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang)
|
||||
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section)
|
||||
{
|
||||
// Copia los punteros
|
||||
this->renderer = renderer;
|
||||
@@ -9,6 +9,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input,
|
||||
this->lang = lang;
|
||||
this->asset = asset;
|
||||
this->input = input;
|
||||
this->section = section;
|
||||
|
||||
// Reserva memoria para los objetos
|
||||
eventHandler = new SDL_Event();
|
||||
@@ -19,8 +20,8 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input,
|
||||
loadMedia();
|
||||
|
||||
// Inicializa variables
|
||||
section.name = SECTION_PROG_INTRO;
|
||||
section.subsection = 0;
|
||||
section->name = SECTION_PROG_INTRO;
|
||||
section->subsection = 0;
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
scene = 1;
|
||||
@@ -181,7 +182,7 @@ void Intro::checkEvents()
|
||||
// Evento de salida de la aplicación
|
||||
if (eventHandler->type == SDL_QUIT)
|
||||
{
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -192,7 +193,7 @@ void Intro::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||
@@ -213,8 +214,8 @@ void Intro::checkInput()
|
||||
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_fire_left, REPEAT_FALSE) || input->checkInput(input_fire_center, REPEAT_FALSE) || input->checkInput(input_fire_right, REPEAT_FALSE))
|
||||
{
|
||||
JA_StopMusic();
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_1;
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,8 +364,8 @@ void Intro::updateScenes()
|
||||
bitmaps[5]->setEnabled(false);
|
||||
texts[8]->setEnabled(false);
|
||||
JA_StopMusic();
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_1;
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -428,16 +429,14 @@ void Intro::render()
|
||||
}
|
||||
|
||||
// Bucle principal
|
||||
section_t Intro::run()
|
||||
void Intro::run()
|
||||
{
|
||||
JA_PlayMusic(music, 0);
|
||||
|
||||
while (section.name == SECTION_PROG_INTRO)
|
||||
while (section->name == SECTION_PROG_INTRO)
|
||||
{
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
}
|
||||
|
||||
return section;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user