Optimizando la intro

This commit is contained in:
2022-11-30 08:26:16 +01:00
parent 3817a01712
commit 2caea7ba6e
4 changed files with 36 additions and 6 deletions

View File

@@ -38,6 +38,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
loadCounter = 0;
lineCounter = 0;
loadingFirstPart = true;
loadRect = {0, 0, 50, 1};
// Ls lineas que tapan la primera textura
for (int i = 0; i < 192; ++i)
@@ -151,7 +152,7 @@ void Intro::updateLoad()
{
// Primera parte de la carga, la parte en blanco ynegro
if (loadingFirstPart)
{
/*{
// Cada 5 pasos el loadCounter se incrementa en uno
const int numSteps = 5;
loadCounter = counter / numSteps;
@@ -168,6 +169,28 @@ void Intro::updateLoad()
}
}
// Una vez actualizadas las 192 lineas, pasa a la segunda fase de la carga
else if (loadCounter == 192)
{
loadingFirstPart = false;
loadCounter = 0;
JA_PlayMusic(loadingSound3);
}
}*/
{
// Cada 5 pasos el loadCounter se incrementa en uno
const int numSteps = 5;
loadCounter = counter / numSteps;
if (loadCounter < 192)
{
const int step = 256 / numSteps;
lines[lineIndex[loadCounter]].x1 = step * (counter % numSteps);
loadRect.x = step * (counter % numSteps);
loadRect.y = lineIndex[loadCounter];
sprite1->setSpriteClip(loadRect);
sprite1->setRect(loadRect);
}
// Una vez actualizadas las 192 lineas, pasa a la segunda fase de la carga
else if (loadCounter == 192)
{
@@ -206,7 +229,7 @@ void Intro::renderLoad()
{
// Carga 1 - Blanco y negro
if (loadingFirstPart)
{
/*{
// Dibuja la textura de pantalla de carga en blanco y negro en pantalla
sprite1->render();
@@ -216,6 +239,9 @@ void Intro::renderLoad()
{
SDL_RenderDrawLine(renderer, lines[i].x1, lines[i].y, lines[i].x2, lines[i].y);
}
}*/
{
sprite1->render();
}
else
// Carga 2 - Color
@@ -271,7 +297,10 @@ void Intro::render()
screen->start();
// Limpia la pantalla
screen->clean();
// screen->clean();
if (!loadingFirstPart)
screen->clean();
// Dibuja la pantalla de carga
renderLoad();