Fade acabado y no convence

This commit is contained in:
2022-09-15 22:41:19 +02:00
parent 8125e47d17
commit 06cb1e748d
3 changed files with 33 additions and 12 deletions

View File

@@ -112,7 +112,10 @@ void Game::checkEventHandler()
case SDL_SCANCODE_M:
board.music = !board.music;
board.music ? JA_ResumeMusic() : JA_PauseMusic();
screen->setFade();
break;
case SDL_SCANCODE_T:
screen->setspectrumFade();
break;
case SDL_SCANCODE_P:
@@ -215,7 +218,7 @@ void Game::update()
checkIfPlayerIsAlive();
checkEndGame();
scoreboard->update();
updateDebugInfo();
updateBlackScreen();
screen->updateFX();
@@ -396,7 +399,7 @@ void Game::killPlayer()
// Sonido
JA_PlaySound(deathSound);
blackScreen = true;
setBlackScreen();
// Crea la nueva habitación y el nuevo jugador
room = new Room(asset->get(currentRoom), renderer, screen, asset, itemTracker, &board.items, debug);
@@ -415,20 +418,29 @@ void Game::reLoadTextures()
text->reLoadTexture();
}
// Establece la pantalla en negro
void Game::setBlackScreen()
{
blackScreen = true;
screen->setspectrumFade();
}
// Actualiza las variables relativas a la pantalla en negro
void Game::updateBlackScreen()
{
if (blackScreen)
{
blackScreenCounter++;
if (blackScreenCounter > 50)
if (screen->spectrumFadeEnded())
{
blackScreen = false;
blackScreenCounter = 0;
player->resume();
room->resume();
blackScreenCounter++;
if (blackScreenCounter > 50)
{
blackScreen = false;
blackScreenCounter = 0;
player->resume();
room->resume();
}
}
}
}

View File

@@ -92,6 +92,9 @@ private:
// Recarga todas las texturas
void reLoadTextures();
// Establece la pantalla en negro
void setBlackScreen();
// Actualiza las variables relativas a la pantalla en negro
void updateBlackScreen();

View File

@@ -287,7 +287,9 @@ void Screen::iniSpectrumFade()
{
spectrumFade = false;
spectrumFadeCounter = 0;
spectrumFadeLenght = 200;
spectrumFadeLenght = 50;
spectrumColor.clear();
color_t c;
c = stringToColor("black");
@@ -327,6 +329,7 @@ void Screen::updateSpectrumFade()
if (spectrumFadeCounter > spectrumFadeLenght)
{
iniSpectrumFade();
SDL_SetTextureColorMod(gameCanvas, 255, 255, 255);
}
}
@@ -339,7 +342,10 @@ void Screen::renderSpectrumFade()
}
const float step = (float)spectrumFadeCounter / (float)spectrumFadeLenght;
SDL_SetTextureColorMod(gameCanvas, 255, 0, 0);
const int max = spectrumColor.size() - 1;
const int index = max + (0 - max) * step;
const color_t c = spectrumColor[index];
SDL_SetTextureColorMod(gameCanvas, c.r, c.g, c.b);
}
// Actualiza los efectos