Ya se dibuja el gif en pantalla

This commit is contained in:
2024-02-07 16:59:25 +01:00
parent 2d045642ff
commit 8e612aaa2e
4 changed files with 92 additions and 42 deletions

View File

@@ -39,6 +39,12 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
}
SDL_SetTextureBlendMode(bgTexture, SDL_BLENDMODE_BLEND);
// Carga la surface con los gráficos de la pantalla de carga
pInit(renderer, 256, 192);
loading_screen = pLoadSurface("data/title/loading_screen_color.gif");
pLoadPal("data/title/loading_screen_color.gif");
pSetSource(loading_screen);
// Inicializa variables
counter = 0;
section->name = SECTION_TITLE;
@@ -48,6 +54,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
marqueeSpeed = 3;
initMarquee();
showCheevos = false;
state = show_loading_screen;
// Crea y rellena la textura para mostrar los logros
createCheevosTexture();
@@ -69,6 +76,7 @@ Title::~Title()
delete cheevosTexture;
delete text;
delete infoText;
pDeleteSurface(loading_screen);
SDL_DestroyTexture(bgTexture);
}
@@ -264,23 +272,43 @@ void Title::update()
// Comprueba las entradas
checkInput();
// Incrementa el contador
counter++;
// Actualiza la marquesina
updateMarquee();
// Actualiza las notificaciones
screen->updateNotifier();
// Si el contador alcanza cierto valor, termina la seccion
if (counter == 2200)
// Incrementa el contador
counter++;
switch (state)
{
if (!showCheevos)
case show_loading_screen:
if (counter == 500)
{
section->name = SECTION_CREDITS;
section->subsection = 0;
counter = 0;
state = show_menu;
}
break;
case fade_loading_screen:
break;
case show_menu:
// Actualiza la marquesina
updateMarquee();
// Si el contador alcanza cierto valor, termina la seccion
if (counter == 2200)
{
if (!showCheevos)
{
section->name = SECTION_CREDITS;
section->subsection = 0;
}
}
break;
default:
break;
}
}
}
@@ -291,16 +319,36 @@ void Title::render()
// Prepara para empezar a dibujar en la textura de juego
screen->start();
// Dibuja la textura de fondo
SDL_RenderCopy(renderer, bgTexture, nullptr, nullptr);
// Dibuja la marquesina
renderMarquee();
// Dibuja la información de logros
if (showCheevos)
switch (state)
{
cheevosSprite->render();
case show_loading_screen:
// Dibuja la textura de fondo
SDL_RenderCopy(renderer, bgTexture, nullptr, nullptr);
// Dibuja la pantalla de carga
pBlit(0, 0, 0, 0, 256, 192);
pFlip(renderer);
break;
case fade_loading_screen:
break;
case show_menu:
// Dibuja la textura de fondo
SDL_RenderCopy(renderer, bgTexture, nullptr, nullptr);
// Dibuja la marquesina
renderMarquee();
// Dibuja la información de logros
if (showCheevos)
{
cheevosSprite->render();
}
break;
default:
break;
}
// Vuelca el contenido del renderizador en pantalla