Añadido efecto de atenuación a la clase screen
Al pausar el juego se atenua la pantalla
This commit is contained in:
@@ -36,6 +36,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
|
||||
shakeEffect.lenght = 8;
|
||||
shakeEffect.remaining = 0;
|
||||
shakeEffect.origin = 0;
|
||||
attenuateEffect = false;
|
||||
|
||||
iniFade();
|
||||
|
||||
@@ -74,6 +75,9 @@ void Screen::blit()
|
||||
// Actualiza y dibuja el efecto de flash en la pantalla
|
||||
doFlash();
|
||||
|
||||
// Atenua la pantalla
|
||||
doAttenuate();
|
||||
|
||||
if (options->video.shaders)
|
||||
{
|
||||
shader::render();
|
||||
@@ -402,9 +406,28 @@ void Screen::doFlash()
|
||||
}
|
||||
}
|
||||
|
||||
// Atenua la pantalla
|
||||
void Screen::doAttenuate()
|
||||
{
|
||||
if (attenuateEffect)
|
||||
{
|
||||
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
|
||||
SDL_SetRenderTarget(renderer, gameCanvas);
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 64);
|
||||
SDL_RenderFillRect(renderer, nullptr);
|
||||
SDL_SetRenderTarget(renderer, temp);
|
||||
}
|
||||
}
|
||||
|
||||
// Activa/desactiva los shaders
|
||||
void Screen::switchShaders()
|
||||
{
|
||||
options->video.shaders = !options->video.shaders;
|
||||
setVideoMode(options->video.mode);
|
||||
}
|
||||
|
||||
// Atenua la pantalla
|
||||
void Screen::attenuate(bool value)
|
||||
{
|
||||
attenuateEffect = value;
|
||||
}
|
||||
@@ -31,6 +31,7 @@ private:
|
||||
int borderHeight; // Anltura del borde
|
||||
SDL_Rect dest; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
|
||||
color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
||||
bool attenuateEffect; // Indica si la pantalla ha de estar atenuada
|
||||
|
||||
struct effect_t
|
||||
{
|
||||
@@ -41,7 +42,7 @@ private:
|
||||
};
|
||||
|
||||
// Variables - Efectos
|
||||
effect_t fadeEffect; // Variable para gestionar el efecto de fade
|
||||
effect_t fadeEffect; // Variable para gestionar el efecto de fade
|
||||
effect_t flashEffect; // Variable para gestionar el efecto de flash
|
||||
|
||||
struct shake_t
|
||||
@@ -75,6 +76,9 @@ private:
|
||||
// Actualiza y dibuja el efecto de flash en la pantalla
|
||||
void doFlash();
|
||||
|
||||
// Atenua la pantalla
|
||||
void doAttenuate();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options_t *options);
|
||||
@@ -139,6 +143,9 @@ public:
|
||||
|
||||
// Activa/desactiva los shaders
|
||||
void switchShaders();
|
||||
|
||||
// Atenua la pantalla
|
||||
void attenuate(bool value);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user