forked from jaildesigner-jailgames/jaildoctors_dilemma
Trabajando en el fade tipo spectrum
This commit is contained in:
@@ -13,9 +13,8 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options, i
|
||||
gameCanvasWidth = gameInternalResX;
|
||||
gameCanvasHeight = gameInternalResY;
|
||||
|
||||
fade = false;
|
||||
fadeCounter = 0;
|
||||
fadeLenght = 200;
|
||||
iniFade();
|
||||
iniSpectrumFade();
|
||||
|
||||
// Define el color del borde para el modo de pantalla completa
|
||||
borderColor = {0x00, 0x00, 0x00};
|
||||
@@ -227,6 +226,31 @@ bool Screen::fadeEnded()
|
||||
return true;
|
||||
}
|
||||
|
||||
// Activa el spectrum fade
|
||||
void Screen::setspectrumFade()
|
||||
{
|
||||
spectrumFade = true;
|
||||
}
|
||||
|
||||
// Comprueba si ha terminado el spectrum fade
|
||||
bool Screen::spectrumFadeEnded()
|
||||
{
|
||||
if (spectrumFade || spectrumFadeCounter > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Inicializa las variables para el fade
|
||||
void Screen::iniFade()
|
||||
{
|
||||
fade = false;
|
||||
fadeCounter = 0;
|
||||
fadeLenght = 200;
|
||||
}
|
||||
|
||||
// Actualiza el fade
|
||||
void Screen::updateFade()
|
||||
{
|
||||
@@ -238,8 +262,7 @@ void Screen::updateFade()
|
||||
fadeCounter++;
|
||||
if (fadeCounter > fadeLenght)
|
||||
{
|
||||
fade = false;
|
||||
fadeCounter = 0;
|
||||
iniFade();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,14 +282,76 @@ void Screen::renderFade()
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
}
|
||||
|
||||
// Inicializa las variables para el fade spectrum
|
||||
void Screen::iniSpectrumFade()
|
||||
{
|
||||
spectrumFade = false;
|
||||
spectrumFadeCounter = 0;
|
||||
spectrumFadeLenght = 200;
|
||||
|
||||
color_t c;
|
||||
c = stringToColor("black");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("blue");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("red");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("magenta");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("green");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("cyan");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("yellow");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("bright_white");
|
||||
spectrumColor.push_back(c);
|
||||
}
|
||||
|
||||
// Actualiza el spectrum fade
|
||||
void Screen::updateSpectrumFade()
|
||||
{
|
||||
if (!spectrumFade)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
spectrumFadeCounter++;
|
||||
if (spectrumFadeCounter > spectrumFadeLenght)
|
||||
{
|
||||
iniSpectrumFade();
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja el spectrum fade
|
||||
void Screen::renderSpectrumFade()
|
||||
{
|
||||
if (!spectrumFade)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const float step = (float)spectrumFadeCounter / (float)spectrumFadeLenght;
|
||||
SDL_SetTextureColorMod(gameCanvas, 255, 0, 0);
|
||||
}
|
||||
|
||||
// Actualiza los efectos
|
||||
void Screen::updateFX()
|
||||
{
|
||||
updateFade();
|
||||
updateSpectrumFade();
|
||||
}
|
||||
|
||||
// Dibuja los efectos
|
||||
void Screen::renderFX()
|
||||
{
|
||||
renderFade();
|
||||
renderSpectrumFade();
|
||||
}
|
||||
Reference in New Issue
Block a user