Compare commits
2 Commits
0d8207013c
...
4e9135c1af
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e9135c1af | |||
| 354795d52c |
@@ -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
|
||||||
|
|||||||
@@ -346,15 +346,19 @@ void Screen::renderFX()
|
|||||||
void Screen::update()
|
void Screen::update()
|
||||||
{
|
{
|
||||||
updateShake();
|
updateShake();
|
||||||
// updateFlash();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Agita la pantalla
|
// Agita la pantalla
|
||||||
void Screen::shake()
|
void Screen::shake()
|
||||||
{
|
{
|
||||||
|
// Si ya hay un shake effect en marcha no se pilla el origen, solo se renuevan los contadores
|
||||||
|
if (shakeEffect.remaining == 0)
|
||||||
|
{
|
||||||
|
shakeEffect.origin = dest.x;
|
||||||
|
}
|
||||||
|
|
||||||
shakeEffect.remaining = shakeEffect.lenght;
|
shakeEffect.remaining = shakeEffect.lenght;
|
||||||
shakeEffect.counter = shakeEffect.delay;
|
shakeEffect.counter = shakeEffect.delay;
|
||||||
shakeEffect.origin = dest.x;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza la logica para agitar la pantalla
|
// Actualiza la logica para agitar la pantalla
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -221,6 +258,31 @@ void Fade::activate()
|
|||||||
square[num - 1] = temp;
|
square[num - 1] = temp;
|
||||||
num--;
|
num--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Limpia la textura
|
||||||
|
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
|
||||||
|
SDL_SetRenderTarget(renderer, backbuffer);
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
SDL_SetRenderTarget(renderer, temp);
|
||||||
|
|
||||||
|
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;
|
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();
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ HiScoreTable::HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *asset,
|
|||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
manualQuit = false;
|
manualQuit = false;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
counterEnd = 600;
|
counterEnd = 800;
|
||||||
viewArea = {0, 0, param->gameWidth, param->gameHeight};
|
viewArea = {0, 0, param->gameWidth, param->gameHeight};
|
||||||
|
|
||||||
// Crea el contenido de la textura con la lista de puntuaciones
|
// Crea el contenido de la textura con la lista de puntuaciones
|
||||||
@@ -85,10 +85,13 @@ void HiScoreTable::update()
|
|||||||
// Crea el contenido de la textura con la lista de puntuaciones
|
// Crea el contenido de la textura con la lista de puntuaciones
|
||||||
void HiScoreTable::fillTexture()
|
void HiScoreTable::fillTexture()
|
||||||
{
|
{
|
||||||
const color_t orangeColor = {0xFF, 0x7A, 0x00};
|
|
||||||
// hay 27 letras - 7 de puntos quedan 20 caracteres 20 - nameLenght 0 numDots
|
// hay 27 letras - 7 de puntos quedan 20 caracteres 20 - nameLenght 0 numDots
|
||||||
|
const color_t orangeColor = {0xFF, 0x7A, 0x00};
|
||||||
|
const int maxNames = 10;
|
||||||
const int spaceBetweenHeader = 32;
|
const int spaceBetweenHeader = 32;
|
||||||
const int spaceBetweenLines = text->getCharacterSize() * 1.8f;
|
const int spaceBetweenLines = text->getCharacterSize() * 2.0f;
|
||||||
|
const int size = spaceBetweenHeader + spaceBetweenLines * maxNames;
|
||||||
|
const int firstLine = (param->gameHeight - size) / 2;
|
||||||
|
|
||||||
// Pinta en el backbuffer el texto y los sprites
|
// Pinta en el backbuffer el texto y los sprites
|
||||||
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
|
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
|
||||||
@@ -97,13 +100,13 @@ void HiScoreTable::fillTexture()
|
|||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
// Escribe el texto: Mejores puntuaciones
|
// Escribe el texto: Mejores puntuaciones
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 8, lang->getText(42), 1, orangeColor, 1, shdwTxtColor);
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, firstLine, lang->getText(42), 1, orangeColor, 1, shdwTxtColor);
|
||||||
|
|
||||||
// Rellena la lista con nombres
|
// Rellena la lista con nombres
|
||||||
std::vector<std::string> names;
|
std::vector<std::string> names;
|
||||||
names.insert(names.end(), {"Bry", "Usufondo", "G.Lucas", "P.Delgat", "P.Arrabalera", "Pelechano", "Sahuquillo", "Bacteriol", "Pepe", "Rosita"});
|
names.insert(names.end(), {"Bry", "Usufondo", "G.Lucas", "P.Delgat", "P.Arrabalera", "Pelechano", "Sahuquillo", "Bacteriol", "Pepe", "Rosita"});
|
||||||
|
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < maxNames; ++i)
|
||||||
{
|
{
|
||||||
const int nameLenght = names[i].length();
|
const int nameLenght = names[i].length();
|
||||||
const int numDots = 20 - nameLenght;
|
const int numDots = 20 - nameLenght;
|
||||||
@@ -113,7 +116,7 @@ void HiScoreTable::fillTexture()
|
|||||||
dots = dots + ".";
|
dots = dots + ".";
|
||||||
}
|
}
|
||||||
const std::string line = names[i] + dots + "0000000";
|
const std::string line = names[i] + dots + "0000000";
|
||||||
text->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, (i * spaceBetweenLines) + spaceBetweenHeader, line, 1, orangeColor, 1, shdwTxtColor);
|
text->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, (i * spaceBetweenLines) + firstLine + spaceBetweenHeader, line, 1, orangeColor, 1, shdwTxtColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el destino de renderizado
|
// Cambia el destino de renderizado
|
||||||
@@ -133,7 +136,7 @@ void HiScoreTable::render()
|
|||||||
background->render();
|
background->render();
|
||||||
|
|
||||||
// Establece la ventana del backbuffer
|
// Establece la ventana del backbuffer
|
||||||
viewArea.y = std::max(8, param->gameHeight - counter + 100);
|
viewArea.y = std::max(0, param->gameHeight - counter + 100);
|
||||||
|
|
||||||
// Copia el backbuffer al renderizador
|
// Copia el backbuffer al renderizador
|
||||||
SDL_RenderCopy(renderer, backbuffer, nullptr, &viewArea);
|
SDL_RenderCopy(renderer, backbuffer, nullptr, &viewArea);
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ void Instructions::render()
|
|||||||
|
|
||||||
// Pinta en el backbuffer el texto y los sprites
|
// Pinta en el backbuffer el texto y los sprites
|
||||||
SDL_SetRenderTarget(renderer, backbuffer);
|
SDL_SetRenderTarget(renderer, backbuffer);
|
||||||
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
SDL_SetRenderDrawColor(renderer, 255, bgColor.g, bgColor.b, 255);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
// Escribe el texto
|
// Escribe el texto
|
||||||
@@ -168,7 +168,7 @@ void Instructions::render()
|
|||||||
screen->clean(bgColor);
|
screen->clean(bgColor);
|
||||||
|
|
||||||
// Establece la ventana del backbuffer
|
// Establece la ventana del backbuffer
|
||||||
window.y = std::max(8, param->gameHeight - counter + 100);
|
window.y = std::max(0, param->gameHeight - counter + 100);
|
||||||
|
|
||||||
// Copia el backbuffer al renderizador
|
// Copia el backbuffer al renderizador
|
||||||
SDL_RenderCopy(renderer, backbuffer, nullptr, &window);
|
SDL_RenderCopy(renderer, backbuffer, nullptr, &window);
|
||||||
|
|||||||
@@ -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