Limpieza de código en la lógica y dibujado del titulo
This commit is contained in:
@@ -190,9 +190,6 @@ void Title::init()
|
||||
// Actualiza las variables del objeto
|
||||
void Title::update()
|
||||
{
|
||||
// Comprueba las entradas
|
||||
checkInput();
|
||||
|
||||
// Calcula la lógica de los objetos
|
||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||
{
|
||||
@@ -229,7 +226,7 @@ void Title::update()
|
||||
// Sección 2 - Titulo vibrando
|
||||
case SUBSECTION_TITLE_2:
|
||||
{
|
||||
// Agita la pantalla
|
||||
// Agita el logo
|
||||
static const int v[] = {-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 0};
|
||||
static const int a = coffeeBitmap->getPosX();
|
||||
static const int b = crisisBitmap->getPosX();
|
||||
@@ -241,10 +238,10 @@ void Title::update()
|
||||
dustBitmapL->update();
|
||||
|
||||
step++;
|
||||
|
||||
if (step == 33)
|
||||
{
|
||||
section->subsection = SUBSECTION_TITLE_3;
|
||||
step = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -262,6 +259,7 @@ void Title::update()
|
||||
JA_PlayMusic(titleMusic);
|
||||
}
|
||||
|
||||
// Actualiza los objetos
|
||||
dustBitmapR->update();
|
||||
dustBitmapL->update();
|
||||
|
||||
@@ -357,11 +355,6 @@ void Title::update()
|
||||
|
||||
// Dibuja el objeto en pantalla
|
||||
void Title::render()
|
||||
{
|
||||
switch (section->subsection)
|
||||
{
|
||||
// Sección 1 - Titulo desplazandose
|
||||
case SUBSECTION_TITLE_1:
|
||||
{
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
@@ -370,68 +363,25 @@ void Title::render()
|
||||
screen->clean(bgColor);
|
||||
|
||||
// Dibuja el tileado de fondo
|
||||
// SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
||||
backgroundObj->render();
|
||||
SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
||||
// backgroundObj->render();
|
||||
|
||||
// Dibuja los objetos
|
||||
// Dibuja el logo
|
||||
coffeeBitmap->render();
|
||||
crisisBitmap->render();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
}
|
||||
break;
|
||||
// Dibuja el polvillo del logo
|
||||
dustBitmapR->render();
|
||||
dustBitmapL->render();
|
||||
|
||||
// Sección 2 - Titulo vibrando
|
||||
case SUBSECTION_TITLE_2:
|
||||
if (section->subsection == SUBSECTION_TITLE_3)
|
||||
{
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean(bgColor);
|
||||
|
||||
// Dibuja el tileado de fondo
|
||||
// SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
||||
backgroundObj->render();
|
||||
|
||||
// Dibuja los objetos
|
||||
coffeeBitmap->render();
|
||||
crisisBitmap->render();
|
||||
|
||||
dustBitmapR->render();
|
||||
dustBitmapL->render();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// Sección 3 - La pantalla de titulo con el menú y la música
|
||||
case SUBSECTION_TITLE_3:
|
||||
{ // Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean(bgColor);
|
||||
|
||||
// Dibuja el tileado de fondo
|
||||
// SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
||||
backgroundObj->render();
|
||||
|
||||
coffeeBitmap->render();
|
||||
crisisBitmap->render();
|
||||
|
||||
// Dibuja el polvillo del título
|
||||
dustBitmapR->render();
|
||||
dustBitmapL->render();
|
||||
|
||||
// PRESS ANY KEY!
|
||||
if (counter % 50 > 14)
|
||||
{
|
||||
text1->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_THIRD_QUARTER_Y + BLOCK, lang->getText(23), 1, noColor, 1, shdwTxtColor);
|
||||
}
|
||||
}
|
||||
|
||||
// Fade
|
||||
fade->render();
|
||||
@@ -439,12 +389,6 @@ void Title::render()
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba los eventos
|
||||
void Title::checkEvents()
|
||||
@@ -463,18 +407,6 @@ void Title::checkEvents()
|
||||
{
|
||||
reLoadTextures();
|
||||
}
|
||||
|
||||
if (section->subsection == SUBSECTION_TITLE_3)
|
||||
{ // Si se pulsa alguna tecla durante la tercera sección del titulo
|
||||
if ((eventHandler->type == SDL_KEYUP) || (eventHandler->type == SDL_JOYBUTTONUP))
|
||||
{
|
||||
// Muestra el menu
|
||||
menuVisible = true;
|
||||
|
||||
// Reinicia el contador
|
||||
counter = TITLE_COUNTER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,6 +432,12 @@ void Title::checkInput()
|
||||
{
|
||||
screen->incWindowSize();
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_accept, REPEAT_FALSE))
|
||||
{
|
||||
fade->activateFade();
|
||||
postFade = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el tileado de fondo
|
||||
@@ -544,6 +482,7 @@ void Title::run()
|
||||
{
|
||||
while (section->name == SECTION_PROG_TITLE)
|
||||
{
|
||||
checkInput();
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
|
||||
Reference in New Issue
Block a user