Se puede saltar la animación del titulo y empezar a jugar directamente

This commit is contained in:
2024-06-30 15:32:39 +02:00
parent 8340bdfe32
commit b278941918
2 changed files with 48 additions and 49 deletions

View File

@@ -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")); 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); miniLogoSprite = new Sprite(GAMECANVAS_CENTER_X - miniLogoTexture->getWidth() / 2, 0, miniLogoTexture->getWidth(), miniLogoTexture->getHeight(), miniLogoTexture, renderer);
backgroundObj = new Background(renderer, screen, asset, param); background = new Background(renderer, screen, asset, param);
backgroundObj->setSrcDest(windowArea); background->setSrcDest(windowArea);
backgroundObj->setDstDest(windowArea); background->setDstDest(windowArea);
backgroundObj->setCloudsSpeed(-0.5f); background->setCloudsSpeed(-0.5f);
backgroundObj->setGradientNumber(1); background->setGradientNumber(1);
backgroundObj->setTransition(0.8f); background->setTransition(0.8f);
tiledbg = new Tiledbg(renderer, screen, asset, {0, 0, param->gameWidth, param->gameHeight}); tiledbg = new Tiledbg(renderer, screen, asset, {0, 0, param->gameWidth, param->gameHeight});
@@ -56,7 +56,7 @@ Title::~Title()
delete miniLogoTexture; delete miniLogoTexture;
delete miniLogoSprite; delete miniLogoSprite;
delete backgroundObj; delete background;
delete tiledbg; delete tiledbg;
delete gameLogo; delete gameLogo;
@@ -90,7 +90,34 @@ void Title::update()
ticks = SDL_GetTicks(); ticks = SDL_GetTicks();
// Actualiza el objeto 'background' // 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 // Sección 1 - Titulo animandose
if (section->subsection == SUBSECTION_TITLE_1) if (section->subsection == SUBSECTION_TITLE_1)
@@ -120,34 +147,6 @@ void Title::update()
// Actualiza el mosaico de fondo // Actualiza el mosaico de fondo
tiledbg->update(); 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) else if (counter >= param->titleCounter)
{ {
@@ -168,7 +167,7 @@ void Title::render()
// Dibuja el mosacico de fondo // Dibuja el mosacico de fondo
tiledbg->render(); tiledbg->render();
// backgroundObj->render(); // background->render();
// Dinuja el logo con el título del juego // Dinuja el logo con el título del juego
gameLogo->render(); gameLogo->render();

View File

@@ -32,18 +32,18 @@ class Title
{ {
private: private:
// Objetos y punteros // Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana SDL_Renderer *renderer; // El renderizador de la ventana
Screen *screen; // Objeto encargado de dibujar en pantalla Screen *screen; // Objeto encargado de dibujar en pantalla
Asset *asset; // Objeto que gestiona todos los ficheros de recursos Asset *asset; // Objeto que gestiona todos los ficheros de recursos
Input *input; // Objeto para leer las entradas de teclado o mando Input *input; // Objeto para leer las entradas de teclado o mando
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
SDL_Event *eventHandler; // Manejador de eventos SDL_Event *eventHandler; // Manejador de eventos
section_t *section; // Indicador para el bucle del titulo section_t *section; // Indicador para el bucle del titulo
Background *backgroundObj; // Objeto para dibujar el fondo del juego Background *background; // Objeto para dibujar el fondo del juego
Tiledbg *tiledbg; // Objeto para dibujar el mosaico animado de fondo Tiledbg *tiledbg; // Objeto para dibujar el mosaico animado de fondo
GameLogo *gameLogo; // Objeto para dibujar el logo con el título del juego GameLogo *gameLogo; // Objeto para dibujar el logo con el título del juego
Texture *miniLogoTexture; // Textura con el logo de JailGames mini Texture *miniLogoTexture; // Textura con el logo de JailGames mini
Sprite *miniLogoSprite; // Sprite 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 *text1; // Objeto de texto para poder escribir textos en pantalla
Text *text2; // Objeto de texto para poder escribir textos en pantalla Text *text2; // Objeto de texto para poder escribir textos en pantalla