Añadido delay final al fade
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
gameWidth 320
|
gameWidth 320
|
||||||
gameHeight 240
|
gameHeight 240
|
||||||
numSquaresWidth 80
|
numSquaresWidth 160
|
||||||
numSquaresHeight 60
|
numSquaresHeight 120
|
||||||
fadeRandomSquaresDelay 1
|
fadeRandomSquaresDelay 1
|
||||||
fadeRandomSquaresMult 8
|
fadeRandomSquaresMult 500
|
||||||
|
fadePostDuration 50
|
||||||
@@ -163,10 +163,11 @@ struct param_t
|
|||||||
|
|
||||||
SDL_Rect scoreboard; // Posición y tamaño del marcador
|
SDL_Rect scoreboard; // Posición y tamaño del marcador
|
||||||
|
|
||||||
int numSquaresWidth;
|
int numSquaresWidth; // Cantidad total de cuadraditos en horizontal para el FADE_RANDOM_SQUARE
|
||||||
int numSquaresHeight;
|
int numSquaresHeight; // Cantidad total de cuadraditos en vertical para el FADE_RANDOM_SQUARE
|
||||||
int fadeRandomSquaresDelay;
|
int fadeRandomSquaresDelay; // Duración entre cada pintado de cuadrados
|
||||||
int fadeRandomSquaresMult;
|
int fadeRandomSquaresMult; // Cantidad de cuadrados que se pintaran cada vez
|
||||||
|
int fadePostDuration; // Duración final del fade
|
||||||
};
|
};
|
||||||
|
|
||||||
// Calcula el cuadrado de la distancia entre dos puntos
|
// Calcula el cuadrado de la distancia entre dos puntos
|
||||||
|
|||||||
@@ -73,6 +73,6 @@ const color_t difficultyEasyColor = {75, 105, 47};
|
|||||||
const color_t difficultyNormalColor = {255, 122, 0};
|
const color_t difficultyNormalColor = {255, 122, 0};
|
||||||
const color_t difficultyHardColor = {118, 66, 138};
|
const color_t difficultyHardColor = {118, 66, 138};
|
||||||
const color_t flashColor = {0xFF, 0xFF, 0xFF};
|
const color_t flashColor = {0xFF, 0xFF, 0xFF};
|
||||||
const color_t fadeColor = {0x17, 0x17, 0x26};
|
const color_t fadeColor = {0x27, 0x27, 0x36};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -34,6 +34,8 @@ void Fade::init()
|
|||||||
r = 0;
|
r = 0;
|
||||||
g = 0;
|
g = 0;
|
||||||
b = 0;
|
b = 0;
|
||||||
|
postDuration = 20;
|
||||||
|
postCounter = 0;
|
||||||
numSquaresWidth = param->numSquaresWidth;
|
numSquaresWidth = param->numSquaresWidth;
|
||||||
numSquaresHeight = param->numSquaresHeight;
|
numSquaresHeight = param->numSquaresHeight;
|
||||||
fadeRandomSquaresDelay = param->fadeRandomSquaresDelay;
|
fadeRandomSquaresDelay = param->fadeRandomSquaresDelay;
|
||||||
@@ -149,7 +151,14 @@ void Fade::update()
|
|||||||
|
|
||||||
if (finished)
|
if (finished)
|
||||||
{
|
{
|
||||||
enabled = false;
|
if (postCounter == postDuration)
|
||||||
|
{
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
postCounter++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
@@ -162,6 +171,7 @@ void Fade::activate()
|
|||||||
enabled = true;
|
enabled = true;
|
||||||
finished = false;
|
finished = false;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
|
postCounter = 0;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@@ -204,15 +214,10 @@ void Fade::activate()
|
|||||||
int num = numSquaresWidth * numSquaresHeight;
|
int num = numSquaresWidth * numSquaresHeight;
|
||||||
while (num > 1)
|
while (num > 1)
|
||||||
{
|
{
|
||||||
// agafa un nombre aleatòri entre 0 i num-1
|
|
||||||
int num_arreu = rand() % num;
|
int num_arreu = rand() % num;
|
||||||
|
|
||||||
// el element triat el swapechem amb l'ultim
|
|
||||||
SDL_Rect temp = square[num_arreu];
|
SDL_Rect temp = square[num_arreu];
|
||||||
square[num_arreu] = square[num - 1];
|
square[num_arreu] = square[num - 1];
|
||||||
square[num - 1] = temp;
|
square[num - 1] = temp;
|
||||||
|
|
||||||
// I ara queda un element menys per desordenar
|
|
||||||
num--;
|
num--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -229,7 +234,8 @@ bool Fade::isEnabled()
|
|||||||
// Comprueba si ha terminado la transicion
|
// Comprueba si ha terminado la transicion
|
||||||
bool Fade::hasEnded()
|
bool Fade::hasEnded()
|
||||||
{
|
{
|
||||||
return finished;
|
// Ha terminado cuando ha finalizado la transición y se ha deshabilitado
|
||||||
|
return !enabled && finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el tipo de fade
|
// Establece el tipo de fade
|
||||||
@@ -245,3 +251,9 @@ void Fade::setColor(Uint8 r, Uint8 g, Uint8 b)
|
|||||||
this->g = g;
|
this->g = g;
|
||||||
this->b = b;
|
this->b = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Establece la duración posterior
|
||||||
|
void Fade::setPost(int value)
|
||||||
|
{
|
||||||
|
postDuration = value;
|
||||||
|
}
|
||||||
@@ -21,19 +21,21 @@ private:
|
|||||||
SDL_Texture *backbuffer; // Textura para usar como backbuffer
|
SDL_Texture *backbuffer; // Textura para usar como backbuffer
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
Uint8 type; // Tipo de fade a realizar
|
Uint8 type; // Tipo de fade a realizar
|
||||||
Uint16 counter; // Contador interno
|
Uint16 counter; // Contador interno
|
||||||
bool enabled; // Indica si el fade está activo
|
bool enabled; // Indica si el fade está activo
|
||||||
bool finished; // Indica si ha terminado la transición
|
bool finished; // Indica si ha terminado la transición
|
||||||
Uint8 r, g, b; // Colores para el fade
|
Uint8 r, g, b; // Colores para el fade
|
||||||
SDL_Rect rect1; // Rectangulo usado para crear los efectos de transición
|
SDL_Rect rect1; // Rectangulo usado para crear los efectos de transición
|
||||||
SDL_Rect rect2; // Rectangulo usado para crear los efectos de transición
|
SDL_Rect rect2; // Rectangulo usado para crear los efectos de transición
|
||||||
int numSquaresWidth; // Cantidad total de cuadraditos en horizontal para el FADE_RANDOM_SQUARE
|
int numSquaresWidth; // Cantidad total de cuadraditos en horizontal para el FADE_RANDOM_SQUARE
|
||||||
int numSquaresHeight; // Cantidad total de cuadraditos en vertical para el FADE_RANDOM_SQUARE
|
int numSquaresHeight; // Cantidad total de cuadraditos en vertical para el FADE_RANDOM_SQUARE
|
||||||
param_t *param; // Puntero con todos los parametros del programa
|
param_t *param; // Puntero con todos los parametros del programa
|
||||||
std::vector<SDL_Rect> square; // Vector con los indices de los cuadrados para el FADE_RANDOM_SQUARE
|
std::vector<SDL_Rect> square; // Vector con los indices de los cuadrados para el FADE_RANDOM_SQUARE
|
||||||
int fadeRandomSquaresDelay;
|
int fadeRandomSquaresDelay; // Duración entre cada pintado de cuadrados
|
||||||
int fadeRandomSquaresMult;
|
int fadeRandomSquaresMult; // Cantidad de cuadrados que se pintaran cada vez
|
||||||
|
int postDuration; // Duración posterior del fade tras finalizar
|
||||||
|
int postCounter; // Contador para la duración posterior
|
||||||
|
|
||||||
// Inicializa las variables
|
// Inicializa las variables
|
||||||
void init();
|
void init();
|
||||||
@@ -65,6 +67,9 @@ public:
|
|||||||
|
|
||||||
// Establece el color del fade
|
// Establece el color del fade
|
||||||
void setColor(Uint8 r, Uint8 g, Uint8 b);
|
void setColor(Uint8 r, Uint8 g, Uint8 b);
|
||||||
|
|
||||||
|
// Establece la duración posterior
|
||||||
|
void setPost(int value);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -20,6 +20,7 @@ void initParam(param_t *param)
|
|||||||
param->numSquaresHeight = 60;
|
param->numSquaresHeight = 60;
|
||||||
param->fadeRandomSquaresDelay = 1;
|
param->fadeRandomSquaresDelay = 1;
|
||||||
param->fadeRandomSquaresMult = 8;
|
param->fadeRandomSquaresMult = 8;
|
||||||
|
param->fadePostDuration = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece valores para los parametros a partir de un fichero de texto
|
// Establece valores para los parametros a partir de un fichero de texto
|
||||||
@@ -97,6 +98,11 @@ bool setOptions(param_t *param, std::string var, std::string value)
|
|||||||
param->fadeRandomSquaresMult = std::stoi(value);
|
param->fadeRandomSquaresMult = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (var == "fadePostDuration")
|
||||||
|
{
|
||||||
|
param->fadePostDuration = std::stoi(value);
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
success = false;
|
success = false;
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ void Title::init()
|
|||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);
|
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);
|
||||||
fade->setType(FADE_RANDOM_SQUARE);
|
fade->setType(FADE_RANDOM_SQUARE);
|
||||||
|
fade->setPost(param->fadePostDuration);
|
||||||
demo = true;
|
demo = true;
|
||||||
|
|
||||||
// Pone valores por defecto a las opciones de control
|
// Pone valores por defecto a las opciones de control
|
||||||
|
|||||||
Reference in New Issue
Block a user