diff --git a/source/title.cpp b/source/title.cpp index 72e0d02..b500e95 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -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(); @@ -358,92 +356,38 @@ void Title::update() // Dibuja el objeto en pantalla void Title::render() { - switch (section->subsection) + // 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 el logo + coffeeBitmap->render(); + crisisBitmap->render(); + + // Dibuja el polvillo del logo + dustBitmapR->render(); + dustBitmapL->render(); + + if (section->subsection == SUBSECTION_TITLE_3) { - // Sección 1 - Titulo desplazandose - case SUBSECTION_TITLE_1: - { - // 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(); - - // Vuelca el contenido del renderizador en pantalla - screen->blit(); - } - break; - - // Sección 2 - Titulo vibrando - case SUBSECTION_TITLE_2: - { - // 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(); - - // Vuelca el contenido del renderizador en pantalla - screen->blit(); } - break; - default: - break; - } + // Fade + fade->render(); + + // Vuelca el contenido del renderizador en pantalla + screen->blit(); } // Comprueba los eventos @@ -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(); diff --git a/source/title.h b/source/title.h index 7da3d01..6875687 100644 --- a/source/title.h +++ b/source/title.h @@ -48,9 +48,9 @@ private: section_t *section; // Indicador para el bucle del titulo Background *backgroundObj; // Objeto para dibujar el fondo del juego - Texture *dustTexture; // Textura con los graficos del polvo - Texture *coffeeTexture; // Textura con los graficos de la palabra coffee - Texture *crisisTexture; // Textura con los graficos de la plabra crisis + Texture *dustTexture; // Textura con los graficos del polvo + Texture *coffeeTexture; // Textura con los graficos de la palabra coffee + Texture *crisisTexture; // Textura con los graficos de la plabra crisis SDL_Rect backgroundWindow; // Ventana visible para la textura de fondo del titulo SDL_Texture *background; // Textura dibujar el fondo del titulo diff --git a/todo.txt b/todo.txt index 5472410..5ff3664 100644 --- a/todo.txt +++ b/todo.txt @@ -6,4 +6,5 @@ [] Hacer el marcador transparente [] Valorar la opcion de que write devuelva texturas con el texto en lugar de pintar letra a letra [] Arreglar los anclajes en la pantalla de game over -[] Al poner pausa, que se sigan moviendo las nubes \ No newline at end of file +[] Al poner pausa, que se sigan moviendo las nubes +[] Revisar la clase Fade \ No newline at end of file