Compare commits
2 Commits
0d8207013c
...
4e9135c1af
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e9135c1af | |||
| 354795d52c |
@@ -8,6 +8,7 @@ numSquaresHeight 120
|
||||
fadeRandomSquaresDelay 1
|
||||
fadeRandomSquaresMult 500
|
||||
fadePostDuration 50
|
||||
venetianSize 16
|
||||
|
||||
#SCOREBOARD
|
||||
scoreboard.x 0
|
||||
|
||||
@@ -346,15 +346,19 @@ void Screen::renderFX()
|
||||
void Screen::update()
|
||||
{
|
||||
updateShake();
|
||||
// updateFlash();
|
||||
}
|
||||
|
||||
// Agita la pantalla
|
||||
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.counter = shakeEffect.delay;
|
||||
shakeEffect.origin = dest.x;
|
||||
}
|
||||
|
||||
// Actualiza la logica para agitar la pantalla
|
||||
|
||||
@@ -175,6 +175,7 @@ struct param_t
|
||||
int fadeRandomSquaresDelay; // Duración entre cada pintado de cuadrados
|
||||
int fadeRandomSquaresMult; // Cantidad de cuadrados que se pintaran cada vez
|
||||
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 titleCounter; // Tiempo de inactividad del titulo
|
||||
|
||||
@@ -80,6 +80,17 @@ void Fade::render()
|
||||
break;
|
||||
}
|
||||
|
||||
case FADE_VENETIAN:
|
||||
{
|
||||
SDL_SetRenderDrawColor(renderer, r, g, b, 0xFF);
|
||||
for (auto rect : square)
|
||||
{
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
@@ -148,6 +159,32 @@ void Fade::update()
|
||||
|
||||
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)
|
||||
@@ -221,6 +258,31 @@ void Fade::activate()
|
||||
square[num - 1] = temp;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define FADE_FULLSCREEN 0
|
||||
#define FADE_CENTER 1
|
||||
#define FADE_RANDOM_SQUARE 2
|
||||
#define FADE_VENETIAN 3
|
||||
|
||||
// Clase Fade
|
||||
class Fade
|
||||
|
||||
@@ -278,7 +278,8 @@ void Game::init(int playerID)
|
||||
demo.counter = 0;
|
||||
|
||||
// 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
|
||||
evaluateAndSetMenace();
|
||||
@@ -1627,52 +1628,21 @@ void Game::updateDeath()
|
||||
JA_Sound_t *sound[4] = {bubble1Sound, bubble2Sound, bubble3Sound, bubble4Sound};
|
||||
JA_PlaySound(sound[index], 0);
|
||||
}
|
||||
|
||||
if (deathCounter == 150)
|
||||
{
|
||||
fade->activate();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (fade->hasEnded())
|
||||
{
|
||||
// section->subsection = SUBSECTION_GAME_GAMEOVER;
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
section->name = SECTION_PROG_HI_SCORE_TABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
void Game::updateBalloons()
|
||||
{
|
||||
@@ -2541,6 +2511,9 @@ void Game::update()
|
||||
// Actualiza el objeto screen
|
||||
screen->update();
|
||||
|
||||
// Actualiza el objeto fade
|
||||
fade->update();
|
||||
|
||||
// Actualiza las variables del jugador
|
||||
updatePlayers();
|
||||
|
||||
@@ -2671,17 +2644,8 @@ void Game::render()
|
||||
// Dibuja el separador del marcador de la zona de juego
|
||||
renderSeparator();
|
||||
|
||||
// Dibuja el sprite del jugador al morir
|
||||
if ((deathCounter <= 150) && !players[0]->isAlive())
|
||||
{
|
||||
renderDeathFade(150 - deathCounter);
|
||||
}
|
||||
|
||||
// Dibuja el fade de fin de juego
|
||||
if ((gameCompleted) && (gameCompletedCounter >= GAME_COMPLETED_START_FADE))
|
||||
{
|
||||
renderDeathFade(gameCompletedCounter - GAME_COMPLETED_START_FADE);
|
||||
}
|
||||
// Dibuja el fade
|
||||
fade->render();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
|
||||
@@ -275,9 +275,6 @@ private:
|
||||
// Actualiza el estado de muerte
|
||||
void updateDeath();
|
||||
|
||||
// Renderiza el fade final cuando se acaba la partida
|
||||
void renderDeathFade(int counter);
|
||||
|
||||
// Actualiza los globos
|
||||
void updateBalloons();
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ HiScoreTable::HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *asset,
|
||||
ticksSpeed = 15;
|
||||
manualQuit = false;
|
||||
counter = 0;
|
||||
counterEnd = 600;
|
||||
counterEnd = 800;
|
||||
viewArea = {0, 0, param->gameWidth, param->gameHeight};
|
||||
|
||||
// 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
|
||||
void HiScoreTable::fillTexture()
|
||||
{
|
||||
const color_t orangeColor = {0xFF, 0x7A, 0x00};
|
||||
// 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 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
|
||||
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
|
||||
@@ -97,13 +100,13 @@ void HiScoreTable::fillTexture()
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// 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
|
||||
std::vector<std::string> names;
|
||||
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 numDots = 20 - nameLenght;
|
||||
@@ -113,7 +116,7 @@ void HiScoreTable::fillTexture()
|
||||
dots = dots + ".";
|
||||
}
|
||||
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
|
||||
@@ -133,7 +136,7 @@ void HiScoreTable::render()
|
||||
background->render();
|
||||
|
||||
// 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
|
||||
SDL_RenderCopy(renderer, backbuffer, nullptr, &viewArea);
|
||||
|
||||
@@ -106,7 +106,7 @@ void Instructions::render()
|
||||
|
||||
// Pinta en el backbuffer el texto y los sprites
|
||||
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);
|
||||
|
||||
// Escribe el texto
|
||||
@@ -168,7 +168,7 @@ void Instructions::render()
|
||||
screen->clean(bgColor);
|
||||
|
||||
// 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
|
||||
SDL_RenderCopy(renderer, backbuffer, nullptr, &window);
|
||||
|
||||
@@ -21,6 +21,7 @@ void initParam(param_t *param)
|
||||
param->fadeRandomSquaresDelay = 1;
|
||||
param->fadeRandomSquaresMult = 8;
|
||||
param->fadePostDuration = 20;
|
||||
param->venetianSize = 16;
|
||||
|
||||
// Posició del texto para empezar a jugar
|
||||
param->pressStart = 180;
|
||||
@@ -155,6 +156,11 @@ bool setOptions(param_t *param, std::string var, std::string value)
|
||||
param->fadePostDuration = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "venetianSize")
|
||||
{
|
||||
param->venetianSize = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "scoreboard.x")
|
||||
{
|
||||
param->scoreboard.x = std::stoi(value);
|
||||
|
||||
Reference in New Issue
Block a user