From ab59604cff805e364261e26620e94808fc3e8e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Valor=20Mart=C3=ADnez?= Date: Tue, 11 Jun 2024 16:08:37 +0200 Subject: [PATCH] =?UTF-8?q?Reestructurando=20la=20l=C3=B3gica=20del=20titu?= =?UTF-8?q?lo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/title.cpp | 61 +++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/source/title.cpp b/source/title.cpp index a811365..72e0d02 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -199,10 +199,10 @@ void Title::update() // Actualiza el contador de ticks ticks = SDL_GetTicks(); + // Actualiza el objeto 'background' backgroundObj->update(); - //screen->update(); - counter++; + // Se realizan diferentes cosas en funcion de la subsección actual switch (section->subsection) { // Sección 1 - Titulo desplazandose @@ -219,7 +219,7 @@ void Title::update() // Pantallazo blanco screen->setFlash({0xFF, 0xFF, 0xFF}, 5); - + // Reproduce el efecto sonoro JA_PlaySound(crashSound); } @@ -253,7 +253,10 @@ void Title::update() case SUBSECTION_TITLE_3: { if (counter > 0) - { // Reproduce la música + { + counter--; + + // Reproduce la música if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED)) { JA_PlayMusic(titleMusic); @@ -367,7 +370,7 @@ void Title::render() screen->clean(bgColor); // Dibuja el tileado de fondo - SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr); + // SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr); backgroundObj->render(); // Dibuja los objetos @@ -381,41 +384,26 @@ void Title::render() // Sección 2 - Titulo vibrando 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 - 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 - screen->start(); + // Limpia la pantalla + screen->clean(bgColor); - // Limpia la pantalla - screen->clean(bgColor); + // Dibuja el tileado de fondo + // SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr); + backgroundObj->render(); - // Dibuja el tileado de fondo - SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr); - backgroundObj->render(); + // Dibuja los objetos + coffeeBitmap->render(); + crisisBitmap->render(); - // Dibuja los objetos - coffeeBitmap->setPosX(a + v[n / 3]); - crisisBitmap->setPosX(b + v[n / 3]); - coffeeBitmap->render(); - crisisBitmap->render(); + dustBitmapR->render(); + dustBitmapL->render(); - dustBitmapR->update(); - dustBitmapL->update(); - dustBitmapR->render(); - dustBitmapL->render(); - - // Vuelca el contenido del renderizador en pantalla - screen->blit(); - } - - section->subsection = SUBSECTION_TITLE_3; + // Vuelca el contenido del renderizador en pantalla + screen->blit(); } break; @@ -429,7 +417,7 @@ void Title::render() screen->clean(bgColor); // Dibuja el tileado de fondo - SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr); + // SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr); backgroundObj->render(); coffeeBitmap->render(); @@ -440,7 +428,6 @@ void Title::render() dustBitmapL->render(); // PRESS ANY KEY! - //if ((counter % 50 > 14) && (menuVisible == false)) 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);