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;
|
gameCanvasWidth = gameInternalResX;
|
||||||
gameCanvasHeight = gameInternalResY;
|
gameCanvasHeight = gameInternalResY;
|
||||||
|
|
||||||
fade = false;
|
iniFade();
|
||||||
fadeCounter = 0;
|
iniSpectrumFade();
|
||||||
fadeLenght = 200;
|
|
||||||
|
|
||||||
// Define el color del borde para el modo de pantalla completa
|
// Define el color del borde para el modo de pantalla completa
|
||||||
borderColor = {0x00, 0x00, 0x00};
|
borderColor = {0x00, 0x00, 0x00};
|
||||||
@@ -227,6 +226,31 @@ bool Screen::fadeEnded()
|
|||||||
return true;
|
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
|
// Actualiza el fade
|
||||||
void Screen::updateFade()
|
void Screen::updateFade()
|
||||||
{
|
{
|
||||||
@@ -238,8 +262,7 @@ void Screen::updateFade()
|
|||||||
fadeCounter++;
|
fadeCounter++;
|
||||||
if (fadeCounter > fadeLenght)
|
if (fadeCounter > fadeLenght)
|
||||||
{
|
{
|
||||||
fade = false;
|
iniFade();
|
||||||
fadeCounter = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,14 +282,76 @@ void Screen::renderFade()
|
|||||||
SDL_RenderFillRect(renderer, &rect);
|
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
|
// Actualiza los efectos
|
||||||
void Screen::updateFX()
|
void Screen::updateFX()
|
||||||
{
|
{
|
||||||
updateFade();
|
updateFade();
|
||||||
|
updateSpectrumFade();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja los efectos
|
// Dibuja los efectos
|
||||||
void Screen::renderFX()
|
void Screen::renderFX()
|
||||||
{
|
{
|
||||||
renderFade();
|
renderFade();
|
||||||
|
renderSpectrumFade();
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifndef SCREEN_H
|
#ifndef SCREEN_H
|
||||||
#define SCREEN_H
|
#define SCREEN_H
|
||||||
@@ -37,9 +38,16 @@ private:
|
|||||||
color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
||||||
|
|
||||||
// EFECTOS
|
// EFECTOS
|
||||||
bool fade; // Indica si esta activo el efecto de fade
|
bool fade; // Indica si esta activo el efecto de fade
|
||||||
int fadeCounter; // Temporizador para el efecto de fade
|
int fadeCounter; // Temporizador para el efecto de fade
|
||||||
int fadeLenght; // Duración del fade
|
int fadeLenght; // Duración del fade
|
||||||
|
bool spectrumFade; // Indica si esta activo el efecto de fade spectrum
|
||||||
|
int spectrumFadeCounter; // Temporizador para el efecto de fade spectrum
|
||||||
|
int spectrumFadeLenght; // Duración del fade spectrum
|
||||||
|
std::vector<color_t> spectrumColor; // Colores para el fade spectrum
|
||||||
|
|
||||||
|
// Inicializa las variables para el fade
|
||||||
|
void iniFade();
|
||||||
|
|
||||||
// Actualiza el fade
|
// Actualiza el fade
|
||||||
void updateFade();
|
void updateFade();
|
||||||
@@ -47,6 +55,15 @@ private:
|
|||||||
// Dibuja el fade
|
// Dibuja el fade
|
||||||
void renderFade();
|
void renderFade();
|
||||||
|
|
||||||
|
// Inicializa las variables para el fade spectrum
|
||||||
|
void iniSpectrumFade();
|
||||||
|
|
||||||
|
// Actualiza el spectrum fade
|
||||||
|
void updateSpectrumFade();
|
||||||
|
|
||||||
|
// Dibuja el spectrum fade
|
||||||
|
void renderSpectrumFade();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options, int gameInternalResX, int gameInternalResY);
|
Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options, int gameInternalResX, int gameInternalResY);
|
||||||
@@ -93,12 +110,17 @@ public:
|
|||||||
// Comprueba si ha terminado el fade
|
// Comprueba si ha terminado el fade
|
||||||
bool fadeEnded();
|
bool fadeEnded();
|
||||||
|
|
||||||
|
// Activa el spectrum fade
|
||||||
|
void setspectrumFade();
|
||||||
|
|
||||||
|
// Comprueba si ha terminado el spectrum fade
|
||||||
|
bool spectrumFadeEnded();
|
||||||
|
|
||||||
// Actualiza los efectos
|
// Actualiza los efectos
|
||||||
void updateFX();
|
void updateFX();
|
||||||
|
|
||||||
//Dibuja los efectos
|
// Dibuja los efectos
|
||||||
void renderFX();
|
void renderFX();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user