diff --git a/source/title.cpp b/source/title.cpp index e840da7..2d34e9c 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -23,12 +23,12 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, miniLogoTexture = new Texture(renderer, asset->get("logo_jailgames_mini.png")); miniLogoSprite = new Sprite(GAMECANVAS_CENTER_X - miniLogoTexture->getWidth() / 2, 0, miniLogoTexture->getWidth(), miniLogoTexture->getHeight(), miniLogoTexture, renderer); - backgroundObj = new Background(renderer, screen, asset, param); - backgroundObj->setSrcDest(windowArea); - backgroundObj->setDstDest(windowArea); - backgroundObj->setCloudsSpeed(-0.5f); - backgroundObj->setGradientNumber(1); - backgroundObj->setTransition(0.8f); + background = new Background(renderer, screen, asset, param); + background->setSrcDest(windowArea); + background->setDstDest(windowArea); + background->setCloudsSpeed(-0.5f); + background->setGradientNumber(1); + background->setTransition(0.8f); tiledbg = new Tiledbg(renderer, screen, asset, {0, 0, param->gameWidth, param->gameHeight}); @@ -56,7 +56,7 @@ Title::~Title() delete miniLogoTexture; delete miniLogoSprite; - delete backgroundObj; + delete background; delete tiledbg; delete gameLogo; @@ -90,7 +90,34 @@ void Title::update() ticks = SDL_GetTicks(); // Actualiza el objeto 'background' - backgroundObj->update(); + background->update(); + + // Comprueba el fade y si se ha acabado + fade->update(); + if (fade->hasEnded()) + { + switch (postFade) + { + case 0: // 1 PLAYER + section->name = SECTION_PROG_GAME; + section->subsection = SUBSECTION_GAME_PLAY_1P; + JA_StopMusic(); + break; + + case 1: // 2 PLAYER + section->name = SECTION_PROG_GAME; + section->subsection = SUBSECTION_GAME_PLAY_2P; + JA_StopMusic(); + break; + + case 3: // TIME OUT + section->name = SECTION_PROG_GAME_DEMO; + break; + + default: + break; + } + } // Sección 1 - Titulo animandose if (section->subsection == SUBSECTION_TITLE_1) @@ -120,34 +147,6 @@ void Title::update() // Actualiza el mosaico de fondo tiledbg->update(); - - // Actualiza la lógica del titulo - fade->update(); - - if (fade->hasEnded()) - { - switch (postFade) - { - case 0: // 1 PLAYER - section->name = SECTION_PROG_GAME; - section->subsection = SUBSECTION_GAME_PLAY_1P; - JA_StopMusic(); - break; - - case 1: // 2 PLAYER - section->name = SECTION_PROG_GAME; - section->subsection = SUBSECTION_GAME_PLAY_2P; - JA_StopMusic(); - break; - - case 3: // TIME OUT - section->name = SECTION_PROG_GAME_DEMO; - break; - - default: - break; - } - } } else if (counter >= param->titleCounter) { @@ -168,7 +167,7 @@ void Title::render() // Dibuja el mosacico de fondo tiledbg->render(); - // backgroundObj->render(); + // background->render(); // Dinuja el logo con el título del juego gameLogo->render(); diff --git a/source/title.h b/source/title.h index fd14b0d..4206df5 100644 --- a/source/title.h +++ b/source/title.h @@ -32,18 +32,18 @@ class Title { private: // Objetos y punteros - SDL_Renderer *renderer; // El renderizador de la ventana - Screen *screen; // Objeto encargado de dibujar en pantalla - Asset *asset; // Objeto que gestiona todos los ficheros de recursos - Input *input; // Objeto para leer las entradas de teclado o mando - Lang *lang; // Objeto para gestionar los textos en diferentes idiomas - SDL_Event *eventHandler; // Manejador de eventos - section_t *section; // Indicador para el bucle del titulo - Background *backgroundObj; // Objeto para dibujar el fondo del juego - Tiledbg *tiledbg; // Objeto para dibujar el mosaico animado de fondo - GameLogo *gameLogo; // Objeto para dibujar el logo con el título del juego - Texture *miniLogoTexture; // Textura con el logo de JailGames mini - Sprite *miniLogoSprite; // Sprite con el logo de JailGames mini + SDL_Renderer *renderer; // El renderizador de la ventana + Screen *screen; // Objeto encargado de dibujar en pantalla + Asset *asset; // Objeto que gestiona todos los ficheros de recursos + Input *input; // Objeto para leer las entradas de teclado o mando + Lang *lang; // Objeto para gestionar los textos en diferentes idiomas + SDL_Event *eventHandler; // Manejador de eventos + section_t *section; // Indicador para el bucle del titulo + Background *background; // Objeto para dibujar el fondo del juego + Tiledbg *tiledbg; // Objeto para dibujar el mosaico animado de fondo + GameLogo *gameLogo; // Objeto para dibujar el logo con el título del juego + Texture *miniLogoTexture; // Textura con el logo de JailGames mini + Sprite *miniLogoSprite; // Sprite con el logo de JailGames mini Text *text1; // Objeto de texto para poder escribir textos en pantalla Text *text2; // Objeto de texto para poder escribir textos en pantalla