Reestructurando la lógica del titulo

This commit is contained in:
2024-06-11 16:08:37 +02:00
parent 27294125fe
commit ab59604cff

View File

@@ -199,10 +199,10 @@ void Title::update()
// Actualiza el contador de ticks // Actualiza el contador de ticks
ticks = SDL_GetTicks(); ticks = SDL_GetTicks();
// Actualiza el objeto 'background'
backgroundObj->update(); backgroundObj->update();
//screen->update();
counter++;
// Se realizan diferentes cosas en funcion de la subsección actual
switch (section->subsection) switch (section->subsection)
{ {
// Sección 1 - Titulo desplazandose // Sección 1 - Titulo desplazandose
@@ -253,7 +253,10 @@ void Title::update()
case SUBSECTION_TITLE_3: case SUBSECTION_TITLE_3:
{ {
if (counter > 0) if (counter > 0)
{ // Reproduce la música {
counter--;
// Reproduce la música
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED)) if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
{ {
JA_PlayMusic(titleMusic); JA_PlayMusic(titleMusic);
@@ -367,7 +370,7 @@ void Title::render()
screen->clean(bgColor); screen->clean(bgColor);
// Dibuja el tileado de fondo // Dibuja el tileado de fondo
SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr); // SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
backgroundObj->render(); backgroundObj->render();
// Dibuja los objetos // Dibuja los objetos
@@ -381,14 +384,6 @@ void Title::render()
// Sección 2 - Titulo vibrando // Sección 2 - Titulo vibrando
case SUBSECTION_TITLE_2: case SUBSECTION_TITLE_2:
{ // Reproduce el efecto sonoro
JA_PlaySound(crashSound);
// Agita la pantalla
const int v[] = {-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 0};
const int a = coffeeBitmap->getPosX();
const int b = crisisBitmap->getPosX();
for (int n = 0; n < 11 * 3; ++n)
{ {
// Prepara para empezar a dibujar en la textura de juego // Prepara para empezar a dibujar en la textura de juego
screen->start(); screen->start();
@@ -397,17 +392,13 @@ void Title::render()
screen->clean(bgColor); screen->clean(bgColor);
// Dibuja el tileado de fondo // Dibuja el tileado de fondo
SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr); // SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
backgroundObj->render(); backgroundObj->render();
// Dibuja los objetos // Dibuja los objetos
coffeeBitmap->setPosX(a + v[n / 3]);
crisisBitmap->setPosX(b + v[n / 3]);
coffeeBitmap->render(); coffeeBitmap->render();
crisisBitmap->render(); crisisBitmap->render();
dustBitmapR->update();
dustBitmapL->update();
dustBitmapR->render(); dustBitmapR->render();
dustBitmapL->render(); dustBitmapL->render();
@@ -415,9 +406,6 @@ void Title::render()
screen->blit(); screen->blit();
} }
section->subsection = SUBSECTION_TITLE_3;
}
break; break;
// Sección 3 - La pantalla de titulo con el menú y la música // Sección 3 - La pantalla de titulo con el menú y la música
@@ -429,7 +417,7 @@ void Title::render()
screen->clean(bgColor); screen->clean(bgColor);
// Dibuja el tileado de fondo // Dibuja el tileado de fondo
SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr); // SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
backgroundObj->render(); backgroundObj->render();
coffeeBitmap->render(); coffeeBitmap->render();
@@ -440,7 +428,6 @@ void Title::render()
dustBitmapL->render(); dustBitmapL->render();
// PRESS ANY KEY! // PRESS ANY KEY!
//if ((counter % 50 > 14) && (menuVisible == false))
if (counter % 50 > 14) 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); text1->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_THIRD_QUARTER_Y + BLOCK, lang->getText(23), 1, noColor, 1, shdwTxtColor);