Añadido FADE_VENETIAN a la clase fade
La clase game utiliza un objeto fade para sus fades en vez de sus propios procedimientos
This commit is contained in:
@@ -8,6 +8,7 @@ numSquaresHeight 120
|
|||||||
fadeRandomSquaresDelay 1
|
fadeRandomSquaresDelay 1
|
||||||
fadeRandomSquaresMult 500
|
fadeRandomSquaresMult 500
|
||||||
fadePostDuration 50
|
fadePostDuration 50
|
||||||
|
venetianSize 16
|
||||||
|
|
||||||
#SCOREBOARD
|
#SCOREBOARD
|
||||||
scoreboard.x 0
|
scoreboard.x 0
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ struct param_t
|
|||||||
int fadeRandomSquaresDelay; // Duración entre cada pintado de cuadrados
|
int fadeRandomSquaresDelay; // Duración entre cada pintado de cuadrados
|
||||||
int fadeRandomSquaresMult; // Cantidad de cuadrados que se pintaran cada vez
|
int fadeRandomSquaresMult; // Cantidad de cuadrados que se pintaran cada vez
|
||||||
int fadePostDuration; // Duración final del fade
|
int fadePostDuration; // Duración final del fade
|
||||||
|
int venetianSize; // Altura de los rectangulos para FADE_VENETIAN
|
||||||
|
|
||||||
int pressStart; // Posición del texto para empezar a jugar
|
int pressStart; // Posición del texto para empezar a jugar
|
||||||
int titleCounter; // Tiempo de inactividad del titulo
|
int titleCounter; // Tiempo de inactividad del titulo
|
||||||
|
|||||||
@@ -80,6 +80,17 @@ void Fade::render()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case FADE_VENETIAN:
|
||||||
|
{
|
||||||
|
SDL_SetRenderDrawColor(renderer, r, g, b, 0xFF);
|
||||||
|
for (auto rect : square)
|
||||||
|
{
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -148,6 +159,32 @@ void Fade::update()
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case FADE_VENETIAN:
|
||||||
|
{
|
||||||
|
// Counter debe ir de 0 a 150
|
||||||
|
if (square.back().h < param->venetianSize)
|
||||||
|
{
|
||||||
|
const Uint8 h = counter / 3;
|
||||||
|
for (int i = 0; i < (int)square.size(); ++i)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
square[i].h = h;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
square[i].h = std::max(square[i - 1].h - 3, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
finished = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finished)
|
if (finished)
|
||||||
@@ -223,6 +260,23 @@ void Fade::activate()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case FADE_VENETIAN:
|
||||||
|
{
|
||||||
|
rect1 = {0, 0, param->gameWidth, 0};
|
||||||
|
square.clear();
|
||||||
|
|
||||||
|
// Añade los cuadrados al vector
|
||||||
|
const int max = param->gameHeight / param->venetianSize;
|
||||||
|
|
||||||
|
for (int i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
rect1.y = i * param->venetianSize;
|
||||||
|
square.push_back(rect1);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#define FADE_FULLSCREEN 0
|
#define FADE_FULLSCREEN 0
|
||||||
#define FADE_CENTER 1
|
#define FADE_CENTER 1
|
||||||
#define FADE_RANDOM_SQUARE 2
|
#define FADE_RANDOM_SQUARE 2
|
||||||
|
#define FADE_VENETIAN 3
|
||||||
|
|
||||||
// Clase Fade
|
// Clase Fade
|
||||||
class Fade
|
class Fade
|
||||||
|
|||||||
@@ -278,7 +278,8 @@ void Game::init(int playerID)
|
|||||||
demo.counter = 0;
|
demo.counter = 0;
|
||||||
|
|
||||||
// Inicializa el objeto para el fundido
|
// Inicializa el objeto para el fundido
|
||||||
fade->setColor(0x27, 0x27, 0x36);
|
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);
|
||||||
|
fade->setType(FADE_VENETIAN);
|
||||||
|
|
||||||
// Con los globos creados, calcula el nivel de amenaza
|
// Con los globos creados, calcula el nivel de amenaza
|
||||||
evaluateAndSetMenace();
|
evaluateAndSetMenace();
|
||||||
@@ -1627,52 +1628,21 @@ void Game::updateDeath()
|
|||||||
JA_Sound_t *sound[4] = {bubble1Sound, bubble2Sound, bubble3Sound, bubble4Sound};
|
JA_Sound_t *sound[4] = {bubble1Sound, bubble2Sound, bubble3Sound, bubble4Sound};
|
||||||
JA_PlaySound(sound[index], 0);
|
JA_PlaySound(sound[index], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (deathCounter == 150)
|
||||||
|
{
|
||||||
|
fade->activate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (fade->hasEnded())
|
||||||
{
|
{
|
||||||
// section->subsection = SUBSECTION_GAME_GAMEOVER;
|
// section->subsection = SUBSECTION_GAME_GAMEOVER;
|
||||||
section->name = SECTION_PROG_TITLE;
|
section->name = SECTION_PROG_HI_SCORE_TABLE;
|
||||||
section->subsection = SUBSECTION_TITLE_1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renderiza el fade final cuando se acaba la partida
|
|
||||||
void Game::renderDeathFade(int counter)
|
|
||||||
{
|
|
||||||
// Counter debe ir de 0 a 150
|
|
||||||
SDL_SetRenderDrawColor(renderer, 0x27, 0x27, 0x36, 255);
|
|
||||||
|
|
||||||
const int desp = 16;
|
|
||||||
const int max = param->gameHeight / desp;
|
|
||||||
if (counter < 150)
|
|
||||||
{
|
|
||||||
// 192 / 6 = 32, 6 cuadrados de 32 pixeles
|
|
||||||
SDL_Rect rect[max];
|
|
||||||
Uint8 h = counter / 3;
|
|
||||||
for (int i = 0; i < max; ++i)
|
|
||||||
{
|
|
||||||
rect[i].x = 0;
|
|
||||||
rect[i].y = i * desp;
|
|
||||||
rect[i].w = param->gameWidth;
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
rect[i].h = h;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rect[i].h = std::max(rect[i - 1].h - 3, 0);
|
|
||||||
}
|
|
||||||
SDL_RenderFillRect(renderer, &rect[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SDL_Rect rect = {0, 0, param->gameWidth, param->gameHeight};
|
|
||||||
SDL_RenderFillRect(renderer, &rect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza los globos
|
// Actualiza los globos
|
||||||
void Game::updateBalloons()
|
void Game::updateBalloons()
|
||||||
{
|
{
|
||||||
@@ -2541,6 +2511,9 @@ void Game::update()
|
|||||||
// Actualiza el objeto screen
|
// Actualiza el objeto screen
|
||||||
screen->update();
|
screen->update();
|
||||||
|
|
||||||
|
// Actualiza el objeto fade
|
||||||
|
fade->update();
|
||||||
|
|
||||||
// Actualiza las variables del jugador
|
// Actualiza las variables del jugador
|
||||||
updatePlayers();
|
updatePlayers();
|
||||||
|
|
||||||
@@ -2671,17 +2644,8 @@ void Game::render()
|
|||||||
// Dibuja el separador del marcador de la zona de juego
|
// Dibuja el separador del marcador de la zona de juego
|
||||||
renderSeparator();
|
renderSeparator();
|
||||||
|
|
||||||
// Dibuja el sprite del jugador al morir
|
// Dibuja el fade
|
||||||
if ((deathCounter <= 150) && !players[0]->isAlive())
|
fade->render();
|
||||||
{
|
|
||||||
renderDeathFade(150 - deathCounter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dibuja el fade de fin de juego
|
|
||||||
if ((gameCompleted) && (gameCompletedCounter >= GAME_COMPLETED_START_FADE))
|
|
||||||
{
|
|
||||||
renderDeathFade(gameCompletedCounter - GAME_COMPLETED_START_FADE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
screen->blit();
|
screen->blit();
|
||||||
|
|||||||
@@ -275,9 +275,6 @@ private:
|
|||||||
// Actualiza el estado de muerte
|
// Actualiza el estado de muerte
|
||||||
void updateDeath();
|
void updateDeath();
|
||||||
|
|
||||||
// Renderiza el fade final cuando se acaba la partida
|
|
||||||
void renderDeathFade(int counter);
|
|
||||||
|
|
||||||
// Actualiza los globos
|
// Actualiza los globos
|
||||||
void updateBalloons();
|
void updateBalloons();
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ void initParam(param_t *param)
|
|||||||
param->fadeRandomSquaresDelay = 1;
|
param->fadeRandomSquaresDelay = 1;
|
||||||
param->fadeRandomSquaresMult = 8;
|
param->fadeRandomSquaresMult = 8;
|
||||||
param->fadePostDuration = 20;
|
param->fadePostDuration = 20;
|
||||||
|
param->venetianSize = 16;
|
||||||
|
|
||||||
// Posició del texto para empezar a jugar
|
// Posició del texto para empezar a jugar
|
||||||
param->pressStart = 180;
|
param->pressStart = 180;
|
||||||
@@ -155,6 +156,11 @@ bool setOptions(param_t *param, std::string var, std::string value)
|
|||||||
param->fadePostDuration = std::stoi(value);
|
param->fadePostDuration = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (var == "venetianSize")
|
||||||
|
{
|
||||||
|
param->venetianSize = std::stoi(value);
|
||||||
|
}
|
||||||
|
|
||||||
else if (var == "scoreboard.x")
|
else if (var == "scoreboard.x")
|
||||||
{
|
{
|
||||||
param->scoreboard.x = std::stoi(value);
|
param->scoreboard.x = std::stoi(value);
|
||||||
|
|||||||
Reference in New Issue
Block a user