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
@@ -219,7 +219,7 @@ void Title::update()
// Pantallazo blanco // Pantallazo blanco
screen->setFlash({0xFF, 0xFF, 0xFF}, 5); screen->setFlash({0xFF, 0xFF, 0xFF}, 5);
// Reproduce el efecto sonoro // Reproduce el efecto sonoro
JA_PlaySound(crashSound); JA_PlaySound(crashSound);
} }
@@ -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,41 +384,26 @@ 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); // Prepara para empezar a dibujar en la textura de juego
screen->start();
// Agita la pantalla // Limpia la pantalla
const int v[] = {-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 0}; screen->clean(bgColor);
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
screen->start();
// Limpia la pantalla // Dibuja el tileado de fondo
screen->clean(bgColor); // SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
backgroundObj->render();
// Dibuja el tileado de fondo // Dibuja los objetos
SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr); coffeeBitmap->render();
backgroundObj->render(); crisisBitmap->render();
// Dibuja los objetos dustBitmapR->render();
coffeeBitmap->setPosX(a + v[n / 3]); dustBitmapL->render();
crisisBitmap->setPosX(b + v[n / 3]);
coffeeBitmap->render();
crisisBitmap->render();
dustBitmapR->update(); // Vuelca el contenido del renderizador en pantalla
dustBitmapL->update(); screen->blit();
dustBitmapR->render();
dustBitmapL->render();
// Vuelca el contenido del renderizador en pantalla
screen->blit();
}
section->subsection = SUBSECTION_TITLE_3;
} }
break; break;
@@ -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);