shakeScreen ya no detiene la ejecución del programa
This commit is contained in:
@@ -5,18 +5,30 @@
|
||||
// Constructor
|
||||
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options_t *options)
|
||||
{
|
||||
// Inicializa variables
|
||||
// Copia punteros
|
||||
this->window = window;
|
||||
this->renderer = renderer;
|
||||
this->options = options;
|
||||
this->asset = asset;
|
||||
|
||||
// Inicializa variables
|
||||
windowWidth = 0;
|
||||
windowHeight = 0;
|
||||
gameCanvasWidth = options->video.gameWidth;
|
||||
gameCanvasHeight = options->video.gameHeight;
|
||||
borderWidth = options->video.border.width * 2;
|
||||
borderHeight = options->video.border.height * 2;
|
||||
notificationLogicalWidth = gameCanvasWidth;
|
||||
notificationLogicalHeight = gameCanvasHeight;
|
||||
dest = {0, 0, 0, 0};
|
||||
borderColor = {0, 0, 0};
|
||||
fade = 0;
|
||||
fadeCounter = 0;
|
||||
fadeLenght = 0;
|
||||
shake.desp = 1;
|
||||
shake.delay = 3;
|
||||
shake.counter = 0;
|
||||
shake.lenght = 8;
|
||||
shake.remaining = 0;
|
||||
shake.origin = 0;
|
||||
|
||||
iniFade();
|
||||
|
||||
@@ -28,9 +40,6 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
|
||||
|
||||
// Establece el modo de video
|
||||
setVideoMode(options->video.mode);
|
||||
|
||||
// Inicializa variables
|
||||
notifyActive = false;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -82,7 +91,7 @@ void Screen::setVideoMode(int videoMode)
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
|
||||
// Esconde la ventana
|
||||
//SDL_HideWindow(window);
|
||||
// SDL_HideWindow(window);
|
||||
|
||||
if (options->video.border.enabled)
|
||||
{
|
||||
@@ -246,23 +255,6 @@ 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()
|
||||
{
|
||||
@@ -312,4 +304,41 @@ void Screen::updateFX()
|
||||
void Screen::renderFX()
|
||||
{
|
||||
renderFade();
|
||||
}
|
||||
|
||||
// Actualiza la lógica de la clase
|
||||
void Screen::update()
|
||||
{
|
||||
updateShake();
|
||||
}
|
||||
|
||||
// Agita la pantalla
|
||||
void Screen::startShake()
|
||||
{
|
||||
shake.remaining = shake.lenght;
|
||||
shake.counter = shake.delay;
|
||||
shake.origin = dest.x;
|
||||
}
|
||||
|
||||
// Actualiza la logica para agitar la pantalla
|
||||
void Screen::updateShake()
|
||||
{
|
||||
if (shake.remaining > 0)
|
||||
{
|
||||
if (shake.counter > 0)
|
||||
{
|
||||
shake.counter--;
|
||||
}
|
||||
else
|
||||
{
|
||||
shake.counter = shake.delay;
|
||||
const int desp = shake.remaining % 2 == 0 ? shake.desp * (-1) : shake.desp;
|
||||
dest.x = shake.origin + desp;
|
||||
shake.remaining--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dest.x = shake.origin;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user