Ya funciona el fade de la pantalla de carga

This commit is contained in:
2024-02-07 18:48:53 +01:00
parent 250efd69bf
commit 5f3ecbbd79
3 changed files with 39 additions and 6 deletions

View File

@@ -281,18 +281,23 @@ void Title::update()
switch (state)
{
case show_loading_screen:
if (counter == 2000)
if (counter == 200)
{
counter = 0;
state = show_menu;
state = fade_loading_screen;
}
break;
case fade_loading_screen:
if (counter % 4 == 0)
if (pFadePal())
{
counter = 0;
state = show_menu;
}
break;
case show_menu:
// Actualiza la marquesina
updateMarquee();
@@ -324,7 +329,7 @@ void Title::render()
case show_loading_screen:
// Dibuja la textura de fondo
SDL_RenderCopy(renderer, bgTexture, nullptr, nullptr);
// Dibuja la pantalla de carga
pCls(4);
pBlit(0, 0, 0, 0, 256, 128);
@@ -332,6 +337,13 @@ void Title::render()
break;
case fade_loading_screen:
// Dibuja la textura de fondo
SDL_RenderCopy(renderer, bgTexture, nullptr, nullptr);
// Dibuja la pantalla de carga
pCls(4);
pBlit(0, 0, 0, 0, 256, 128);
pFlip(renderer);
break;
case show_menu:

View File

@@ -61,7 +61,7 @@ void pBlit(int dx, int dy, int sx, int sy, int w, int h)
{
if (jSourceSurf == NULL)
return;
for (int iy = 0; iy < h; ++iy)
{
for (int ix = 0; ix < w; ++ix)
@@ -140,7 +140,7 @@ void pFlip(SDL_Renderer *renderer)
for (int i = 0; i < jWidth * jHeight; ++i)
pixels[i] = paleta[jScreen->data[i]];
SDL_UnlockTexture(jTex);
SDL_Rect rect = {0,64,256,128};
SDL_Rect rect = {0, 64, 256, 128};
SDL_RenderCopy(renderer, jTex, NULL, &rect);
}
@@ -154,4 +154,23 @@ void pPutPixel(int x, int y, Uint8 color)
Uint8 pGetPixel(int x, int y)
{
return jSourceSurf->data[x + y * jSourceSurf->w];
}
bool pFadePal()
{
paleta[1] = paleta[0];
// Colores pares
for (int i = 18; i > 0; i = i - 2)
{
paleta[i] = paleta[i - 2];
}
// Colores impares
for (int i = 17; i > 1; i = i - 2)
{
paleta[i] = paleta[i - 2];
}
return paleta[15] == paleta[0] ? true : false;
}

View File

@@ -23,3 +23,5 @@ void pLoadPal(const char *filename);
void pCls(Uint8 color);
void pFlip(SDL_Renderer *renderer);
bool pFadePal();