Revisados varios pequeños bugs

This commit is contained in:
2022-10-09 12:58:23 +02:00
parent d77757853d
commit 742ca02573
5 changed files with 225 additions and 142 deletions

View File

@@ -43,6 +43,8 @@ loop=0
frames=20,21,22,23 frames=20,21,22,23
[/animation] [/animation]
[animation] [animation]
name=sideshoot name=sideshoot
speed=5 speed=5
@@ -85,6 +87,52 @@ loop=0
frames=44,45,46,47 frames=44,45,46,47
[/animation] [/animation]
[animation]
name=walk_pwr
speed=3
loop=0
frames=0,1,2,3
[/animation]
[animation]
name=stand_pwr
speed=5
loop=0
frames=4,5,6,7
[/animation]
[animation]
name=walk_1C_pwr
speed=3
loop=0
frames=8,9,10,11
[/animation]
[animation]
name=stand_1C_pwr
speed=5
loop=0
frames=12,13,14,15
[/animation]
[animation]
name=walk_2C_pwr
speed=3
loop=0
frames=16,17,18,19
[/animation]
[animation]
name=stand_2C_pwr
speed=5
loop=0
frames=20,21,22,23
[/animation]
[animation] [animation]
name=sideshoot_pwr name=sideshoot_pwr
speed=2 speed=2

View File

@@ -89,7 +89,7 @@ frames=28,29,30,31
name=sideshoot_pwr name=sideshoot_pwr
speed=2 speed=2
loop=0 loop=0
frames=16,17,18,19,20 frames=16,17,18,19
[/animation] [/animation]
[animation] [animation]

View File

@@ -14,7 +14,7 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr
// Pasa variables // Pasa variables
this->demo.enabled = demo; this->demo.enabled = demo;
this->numPlayers = numPlayers; this->numPlayers = numPlayers;
this->currentStage = 9;//currentStage; this->currentStage = currentStage;
lastStageReached = currentStage; lastStageReached = currentStage;
if (numPlayers == 1) if (numPlayers == 1)
{ // Si solo juega un jugador, permite jugar tanto con teclado como con mando { // Si solo juega un jugador, permite jugar tanto con teclado como con mando
@@ -307,9 +307,6 @@ void Game::init()
totalPowerToCompleteGame += stage[i].powerToComplete; totalPowerToCompleteGame += stage[i].powerToComplete;
} }
balloonsPopped = totalPowerToCompleteGame - 20;
stage[9].currentPower = stage[9].powerToComplete - 20;
// Modo demo // Modo demo
demo.recording = false; demo.recording = false;
demo.counter = 0; demo.counter = 0;
@@ -1526,7 +1523,6 @@ void Game::updateHiScore()
{ {
// Si la puntuación actual es mayor que la máxima puntuación // Si la puntuación actual es mayor que la máxima puntuación
for (auto player : players) for (auto player : players)
// for (int i = 0; i < numPlayers; i++)
if (player->getScore() > hiScore) if (player->getScore() > hiScore)
{ {
// Actualiza la máxima puntuación // Actualiza la máxima puntuación
@@ -1548,8 +1544,6 @@ void Game::updateHiScore()
// Transforma un valor numérico en una cadena de 6 cifras // Transforma un valor numérico en una cadena de 6 cifras
std::string Game::updateScoreText(Uint32 num) std::string Game::updateScoreText(Uint32 num)
{ {
// return (std::to_string(num));
if ((num >= 0) && (num <= 9)) if ((num >= 0) && (num <= 9))
{ {
return ("000000" + std::to_string(num)); return ("000000" + std::to_string(num));
@@ -1781,8 +1775,7 @@ void Game::updateDeath()
// Renderiza el fade final cuando se acaba la partida // Renderiza el fade final cuando se acaba la partida
void Game::renderDeathFade(int counter) void Game::renderDeathFade(int counter)
// Counter debe ir de 0 a 150 { // Counter debe ir de 0 a 150
{
SDL_SetRenderDrawColor(renderer, 0x27, 0x27, 0x36, 255); SDL_SetRenderDrawColor(renderer, 0x27, 0x27, 0x36, 255);
if (counter < 150) if (counter < 150)
@@ -1790,15 +1783,19 @@ void Game::renderDeathFade(int counter)
// 192 / 6 = 32, 6 cuadrados de 32 pixeles // 192 / 6 = 32, 6 cuadrados de 32 pixeles
SDL_Rect rect[12]; SDL_Rect rect[12];
Uint8 h = counter / 3; Uint8 h = counter / 3;
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; ++i)
{ {
rect[i].x = 0; rect[i].x = 0;
rect[i].y = i * 16; rect[i].y = i * 16;
rect[i].w = GAME_WIDTH; rect[i].w = GAME_WIDTH;
if (i == 0) if (i == 0)
{
rect[i].h = h; rect[i].h = h;
}
else else
{
rect[i].h = std::max(rect[i - 1].h - 3, 0); rect[i].h = std::max(rect[i - 1].h - 3, 0);
}
SDL_RenderFillRect(renderer, &rect[i]); SDL_RenderFillRect(renderer, &rect[i]);
} }
} }
@@ -2741,10 +2738,7 @@ void Game::update()
checkBulletBalloonCollision(); checkBulletBalloonCollision();
// Comprueba el nivel de amenaza para ver si se han de crear nuevos enemigos // Comprueba el nivel de amenaza para ver si se han de crear nuevos enemigos
if (!gameCompleted)
{
updateMenace(); updateMenace();
}
// Actualiza la velocidad de los enemigos // Actualiza la velocidad de los enemigos
updateBalloonSpeed(); updateBalloonSpeed();
@@ -2897,6 +2891,11 @@ void Game::render()
// Gestiona el nivel de amenaza // Gestiona el nivel de amenaza
void Game::updateMenace() void Game::updateMenace()
{ {
if (gameCompleted)
{
return;
}
const float percent = stage[currentStage].currentPower / stage[currentStage].powerToComplete; const float percent = stage[currentStage].currentPower / stage[currentStage].powerToComplete;
const Uint8 difference = stage[currentStage].maxMenace - stage[currentStage].minMenace; const Uint8 difference = stage[currentStage].maxMenace - stage[currentStage].minMenace;
@@ -3373,20 +3372,12 @@ void Game::runPausedGame()
} }
} }
// Bucle para la pantalla de game over // Actualiza los elementos de la pantalla de game over
void Game::runGameOverScreen() void Game::updateGameOverScreen()
{ {
// Variables // Variables
int postFade = 0; static int postFade = 0;
// Guarda los puntos
saveScoreFile();
// Reinicia el menu
gameOverMenu->reset();
while ((section.subsection == GAME_SECTION_GAMEOVER) && (section.name == PROG_SECTION_GAME))
{
// Comprueba los eventos que hay en la cola // Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0) while (SDL_PollEvent(eventHandler) != 0)
{ {
@@ -3396,6 +3387,15 @@ void Game::runGameOverScreen()
section.name = PROG_SECTION_QUIT; section.name = PROG_SECTION_QUIT;
break; break;
} }
else if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
{
if (gameCompleted)
{
postFade = 1;
fade->activateFade();
JA_PlaySound(itemPickUpSound);
}
}
} }
// Calcula la lógica de los objetos // Calcula la lógica de los objetos
@@ -3406,24 +3406,20 @@ void Game::runGameOverScreen()
// Actualiza la lógica del menu // Actualiza la lógica del menu
gameOverMenu->update(); gameOverMenu->update();
// Actualiza el fade
fade->update(); fade->update();
// Si ha terminado el fade, actua segun se haya operado
if (fade->hasEnded()) if (fade->hasEnded())
{ {
switch (postFade) switch (postFade)
{ {
case 0: // YES case 0: // YES
if (!gameCompleted)
{ // Si el juego no se ha terminado, el menu actua normal
section.name = PROG_SECTION_GAME; section.name = PROG_SECTION_GAME;
deleteAllVectorObjects(); deleteAllVectorObjects();
init(); init();
section.subsection = numPlayers == 1 ? GAME_SECTION_PLAY_1P : GAME_SECTION_PLAY_2P; section.subsection = numPlayers == 1 ? GAME_SECTION_PLAY_1P : GAME_SECTION_PLAY_2P;
}
else
{ // Si ha completado el juego, siempre vuelve a la pantalla de titulo
section.name = PROG_SECTION_TITLE;
section.subsection = TITLE_SECTION_1;
}
break; break;
case 1: // NO case 1: // NO
@@ -3434,11 +3430,36 @@ void Game::runGameOverScreen()
default: default:
break; break;
} }
}
// Comprueba las entradas para el menu solo si no esta el juego completo
if (!gameCompleted)
{
gameOverMenu->checkInput();
// Comprueba si se ha seleccionado algún item del menú
switch (gameOverMenu->getItemSelected())
{
case 0: // YES
postFade = 0;
fade->activateFade();
break;
case 1: // NO
postFade = 1;
fade->activateFade();
break;
default:
break; break;
} }
} }
}
}
// Dibuja los elementos de la pantalla de game over
void Game::renderGameOverScreen()
{
// Prepara para empezar a dibujar en la textura de juego // Prepara para empezar a dibujar en la textura de juego
screen->start(); screen->start();
@@ -3458,6 +3479,12 @@ void Game::runGameOverScreen()
// Dibuja los objetos // Dibuja los objetos
if (numPlayers == 1) if (numPlayers == 1)
{ {
// Congratulations!!
if (gameCompleted)
{
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 8), lang->getText(50));
}
// Game Over // Game Over
textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 6), lang->getText(43)); textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 6), lang->getText(43));
@@ -3466,6 +3493,12 @@ void Game::runGameOverScreen()
} }
else else
{ {
// Congratulations!!
if (gameCompleted)
{
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 9), lang->getText(50));
}
// Game Over // Game Over
textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 7), lang->getText(43)); textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 7), lang->getText(43));
@@ -3488,26 +3521,21 @@ void Game::runGameOverScreen()
// Vuelca el contenido del renderizador en pantalla // Vuelca el contenido del renderizador en pantalla
screen->blit(); screen->blit();
}
// Comprueba las entradas para el menu // Bucle para la pantalla de game over
gameOverMenu->checkInput(); void Game::runGameOverScreen()
{
// Guarda los puntos
saveScoreFile();
// Comprueba si se ha seleccionado algún item del menú // Reinicia el menu
switch (gameOverMenu->getItemSelected()) gameOverMenu->reset();
while ((section.subsection == GAME_SECTION_GAMEOVER) && (section.name == PROG_SECTION_GAME))
{ {
case 0: // YES updateGameOverScreen();
postFade = 0; renderGameOverScreen();
fade->activateFade();
break;
case 1: // NO
postFade = 1;
fade->activateFade();
break;
default:
break;
}
} }
} }
@@ -3554,7 +3582,7 @@ void Game::initPaths()
const int centerPoint = PLAY_AREA_CENTER_Y - (BLOCK * 2); const int centerPoint = PLAY_AREA_CENTER_Y - (BLOCK * 2);
const int distance = (PLAY_AREA_BOTTOM) - (PLAY_AREA_CENTER_Y - 16); const int distance = (PLAY_AREA_BOTTOM) - (PLAY_AREA_CENTER_Y - 16);
for (int i = 0; i < STAGE_COUNTER; i++) for (int i = 0; i < STAGE_COUNTER; ++i)
{ {
if (i < firstPart) if (i < firstPart)
{ {
@@ -3584,7 +3612,7 @@ void Game::initPaths()
const float distance1 = finish1 - start1; const float distance1 = finish1 - start1;
const float distance2 = finish2 - start2; const float distance2 = finish2 - start2;
for (int i = 0; i < STAGE_COUNTER; i++) for (int i = 0; i < STAGE_COUNTER; ++i)
{ {
if (i < firstPart) if (i < firstPart)
{ {
@@ -3592,10 +3620,12 @@ void Game::initPaths()
getReadyBitmapPath[i] *= distance1; getReadyBitmapPath[i] *= distance1;
getReadyBitmapPath[i] -= size; getReadyBitmapPath[i] -= size;
} }
else if (i < secondPart) else if (i < secondPart)
{ {
getReadyBitmapPath[i] = (int)finish1; getReadyBitmapPath[i] = (int)finish1;
} }
else else
{ {
getReadyBitmapPath[i] = sin[(int)((i - 150) * 1.8f)]; getReadyBitmapPath[i] = sin[(int)((i - 150) * 1.8f)];

View File

@@ -467,6 +467,12 @@ private:
// Bucle para el menu de pausa del juego // Bucle para el menu de pausa del juego
void runPausedGame(); void runPausedGame();
// Actualiza los elementos de la pantalla de game over
void updateGameOverScreen();
// Dibuja los elementos de la pantalla de game over
void renderGameOverScreen();
// Bucle para la pantalla de game over // Bucle para la pantalla de game over
void runGameOverScreen(); void runGameOverScreen();

View File

@@ -236,7 +236,6 @@ void Player::setAnimation()
} }
const std::string aPowerUp = powerUp ? "_pwr" : ""; const std::string aPowerUp = powerUp ? "_pwr" : "";
//const std::string aPowerUp = "";
const std::string aWalking = statusWalking == PLAYER_STATUS_WALKING_STOP ? "stand" : "walk"; const std::string aWalking = statusWalking == PLAYER_STATUS_WALKING_STOP ? "stand" : "walk";
const std::string aFiring = statusFiring == PLAYER_STATUS_FIRING_UP ? "centershoot" : "sideshoot"; const std::string aFiring = statusFiring == PLAYER_STATUS_FIRING_UP ? "centershoot" : "sideshoot";