Canviats defines per constexpr i enum class
Canviats punters a unique_ptr Afegit const a alguns metodes de classse fix: el segon jugador no podia unirse a la partida new: Quan els dos jugadors han decidit no continuar, ja no poden continuar i el marcador així ho reflectix fix: al posar el nom per segona vegada en la mateixa partida, no es reseteja la posició del selector fix: el fade venetian no netejava la textura i de vegades eixien gràfics corruptes fix: ara grava a disco cada vegada que es posa nom al morir
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
#include "manage_hiscore_table.h" // for ManageHiScoreTable
|
||||
#include "options.h" // for options
|
||||
#include "param.h" // for param
|
||||
#include "player.h" // for Player, PLAYER_STATUS_PLAYING, PLA...
|
||||
#include "player.h" // for Player, playerStatus::PLAYING, PLA...
|
||||
#include "scoreboard.h" // for Scoreboard, scoreboard_modes_e
|
||||
#include "screen.h" // for Screen
|
||||
#include "smart_sprite.h" // for SmartSprite
|
||||
@@ -155,7 +155,7 @@ void Game::init(int playerID)
|
||||
Player *player = getPlayer(playerID);
|
||||
|
||||
// Cambia el estado del jugador seleccionado
|
||||
player->setStatusPlaying(PLAYER_STATUS_PLAYING);
|
||||
player->setStatusPlaying(playerStatus::PLAYING);
|
||||
|
||||
// Como es el principio del juego, empieza sin inmunidad
|
||||
player->setInvulnerable(false);
|
||||
@@ -164,25 +164,31 @@ void Game::init(int playerID)
|
||||
switch (difficulty)
|
||||
{
|
||||
case DIFFICULTY_EASY:
|
||||
{
|
||||
defaultEnemySpeed = BALLOON_SPEED_1;
|
||||
difficultyScoreMultiplier = 0.5f;
|
||||
difficultyColor = difficultyEasyColor;
|
||||
scoreboard->setColor(difficultyColor);
|
||||
break;
|
||||
}
|
||||
|
||||
case DIFFICULTY_NORMAL:
|
||||
{
|
||||
defaultEnemySpeed = BALLOON_SPEED_1;
|
||||
difficultyScoreMultiplier = 1.0f;
|
||||
difficultyColor = difficultyNormalColor;
|
||||
scoreboard->setColor(scoreboardColor);
|
||||
break;
|
||||
}
|
||||
|
||||
case DIFFICULTY_HARD:
|
||||
{
|
||||
defaultEnemySpeed = BALLOON_SPEED_5;
|
||||
difficultyScoreMultiplier = 1.5f;
|
||||
difficultyColor = difficultyHardColor;
|
||||
scoreboard->setColor(difficultyColor);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -195,10 +201,10 @@ void Game::init(int playerID)
|
||||
scoreboard->setName(player->getScoreBoardPanel(), player->getName());
|
||||
if (player->isWaiting())
|
||||
{
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), SCOREBOARD_MODE_GAME_OVER);
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), scoreboardMode::WAITING);
|
||||
}
|
||||
}
|
||||
scoreboard->setMode(SCOREBOARD_CENTER_PANEL, SCOREBOARD_MODE_STAGE_INFO);
|
||||
scoreboard->setMode(SCOREBOARD_CENTER_PANEL, scoreboardMode::STAGE_INFO);
|
||||
|
||||
// Resto de variables
|
||||
hiScore.score = options.game.hiScoreTable[0].score;
|
||||
@@ -258,7 +264,7 @@ void Game::init(int playerID)
|
||||
{
|
||||
const int otherPlayer = playerID == 1 ? 2 : 1;
|
||||
Player *player = getPlayer(otherPlayer);
|
||||
player->setStatusPlaying(PLAYER_STATUS_PLAYING);
|
||||
player->setStatusPlaying(playerStatus::PLAYING);
|
||||
}
|
||||
|
||||
for (auto player : players)
|
||||
@@ -277,8 +283,8 @@ void Game::init(int playerID)
|
||||
JA_EnableSound(false);
|
||||
|
||||
// Configura los marcadores
|
||||
scoreboard->setMode(SCOREBOARD_LEFT_PANEL, SCOREBOARD_MODE_DEMO);
|
||||
scoreboard->setMode(SCOREBOARD_RIGHT_PANEL, SCOREBOARD_MODE_DEMO);
|
||||
scoreboard->setMode(SCOREBOARD_LEFT_PANEL, scoreboardMode::DEMO);
|
||||
scoreboard->setMode(SCOREBOARD_RIGHT_PANEL, scoreboardMode::DEMO);
|
||||
}
|
||||
|
||||
initPaths();
|
||||
@@ -859,12 +865,13 @@ void Game::updatePlayers()
|
||||
player->update();
|
||||
|
||||
if (player->isPlaying())
|
||||
{ // Comprueba la colisión entre el jugador y los globos
|
||||
{
|
||||
// Comprueba la colisión entre el jugador y los globos
|
||||
if (checkPlayerBalloonCollision(player))
|
||||
{
|
||||
killPlayer(player);
|
||||
|
||||
if (demo.enabled && allPlayersAreWaiting())
|
||||
if (demo.enabled && allPlayersAreNotPlaying())
|
||||
{
|
||||
fade->setType(FADE_RANDOM_SQUARE);
|
||||
fade->activate();
|
||||
@@ -947,8 +954,18 @@ void Game::updateStage()
|
||||
// Actualiza el estado de fin de la partida
|
||||
void Game::updateGameOver()
|
||||
{
|
||||
// Comprueba si todos los jugadores estan muertos
|
||||
// Comprueba si todos los jugadores estan esperando
|
||||
if (allPlayersAreWaiting())
|
||||
{
|
||||
// Entonces los pone en estado de Game Over
|
||||
for (auto player : players)
|
||||
{
|
||||
player->setStatusPlaying(playerStatus::GAME_OVER);
|
||||
}
|
||||
}
|
||||
|
||||
// Si todos estan en estado de Game Over
|
||||
if (allPlayersAreGameOver())
|
||||
{
|
||||
if (gameOverCounter > 0)
|
||||
{
|
||||
@@ -1745,7 +1762,7 @@ void Game::killPlayer(Player *player)
|
||||
JA_PlaySound(playerCollisionSound);
|
||||
screen->shake();
|
||||
JA_PlaySound(coffeeOutSound);
|
||||
player->setStatusPlaying(PLAYER_STATUS_DYING);
|
||||
player->setStatusPlaying(playerStatus::DYING);
|
||||
if (!demo.enabled)
|
||||
{ // En el modo DEMO ni se para la musica ni se añade la puntuación a la tabla
|
||||
allPlayersAreNotPlaying() ? JA_StopMusic() : JA_ResumeMusic();
|
||||
@@ -2237,16 +2254,12 @@ void Game::checkInput()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (player->isContinue())
|
||||
else if (player->isContinue() || player->isWaiting())
|
||||
{
|
||||
// Si no está jugando, el botón de start le permite continuar jugando
|
||||
if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index))
|
||||
{
|
||||
// Si no ha entrado ya en el estado de game over, entonces se puede continuar
|
||||
if (gameOverCounter == GAME_OVER_COUNTER)
|
||||
{
|
||||
player->setStatusPlaying(PLAYER_STATUS_PLAYING);
|
||||
}
|
||||
player->setStatusPlaying(playerStatus::PLAYING);
|
||||
}
|
||||
|
||||
// Si está continuando, los botones de fuego hacen decrementar el contador
|
||||
@@ -2269,7 +2282,7 @@ void Game::checkInput()
|
||||
{
|
||||
player->setInput(input_start);
|
||||
addScoreToScoreBoard(player->getRecordName(), player->getScore());
|
||||
player->setStatusPlaying(PLAYER_STATUS_CONTINUE);
|
||||
player->setStatusPlaying(playerStatus::CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2296,7 +2309,7 @@ void Game::checkInput()
|
||||
{
|
||||
player->setInput(input_start);
|
||||
addScoreToScoreBoard(player->getRecordName(), player->getScore());
|
||||
player->setStatusPlaying(PLAYER_STATUS_CONTINUE);
|
||||
player->setStatusPlaying(playerStatus::CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2403,7 +2416,7 @@ void Game::checkMusicStatus()
|
||||
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
||||
{
|
||||
// Si se ha completado el juego o los jugadores han terminado, detiene la música
|
||||
gameCompleted || allPlayersAreWaiting() ? JA_StopMusic() : JA_PlayMusic(music);
|
||||
gameCompleted || allPlayersAreGameOver() ? JA_StopMusic() : JA_PlayMusic(music);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2589,6 +2602,18 @@ bool Game::allPlayersAreWaiting()
|
||||
return success;
|
||||
}
|
||||
|
||||
// Comprueba si todos los jugadores han terminado de jugar
|
||||
bool Game::allPlayersAreGameOver()
|
||||
{
|
||||
bool success = true;
|
||||
for (auto player : players)
|
||||
{
|
||||
success &= player->isGameOver();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
// Comprueba si todos los jugadores han terminado de jugar
|
||||
bool Game::allPlayersAreNotPlaying()
|
||||
{
|
||||
@@ -2793,6 +2818,7 @@ void Game::addScoreToScoreBoard(std::string name, int score)
|
||||
const hiScoreEntry_t entry = {trim(name), score};
|
||||
ManageHiScoreTable *manager = new ManageHiScoreTable(&options.game.hiScoreTable);
|
||||
manager->add(entry);
|
||||
manager->saveToFile(asset->get("score.bin"));
|
||||
delete manager;
|
||||
}
|
||||
|
||||
@@ -2808,36 +2834,40 @@ void Game::checkPlayersStatusPlaying()
|
||||
{
|
||||
switch (player->getStatusPlaying())
|
||||
{
|
||||
case PLAYER_STATUS_PLAYING:
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), SCOREBOARD_MODE_SCORE);
|
||||
case playerStatus::PLAYING:
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), scoreboardMode::SCORE);
|
||||
break;
|
||||
|
||||
case PLAYER_STATUS_CONTINUE:
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), SCOREBOARD_MODE_CONTINUE);
|
||||
case playerStatus::CONTINUE:
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), scoreboardMode::CONTINUE);
|
||||
scoreboard->setContinue(player->getScoreBoardPanel(), player->getContinueCounter());
|
||||
break;
|
||||
|
||||
case PLAYER_STATUS_WAITING:
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), SCOREBOARD_MODE_GAME_OVER);
|
||||
case playerStatus::WAITING:
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), scoreboardMode::WAITING);
|
||||
break;
|
||||
|
||||
case PLAYER_STATUS_ENTERING_NAME:
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), SCOREBOARD_MODE_ENTER_NAME);
|
||||
case playerStatus::ENTERING_NAME:
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), scoreboardMode::ENTER_NAME);
|
||||
scoreboard->setRecordName(player->getScoreBoardPanel(), player->getRecordName());
|
||||
scoreboard->setSelectorPos(player->getScoreBoardPanel(), player->getRecordNamePos());
|
||||
break;
|
||||
|
||||
case PLAYER_STATUS_DYING:
|
||||
case playerStatus::DYING:
|
||||
break;
|
||||
|
||||
case PLAYER_STATUS_DIED:
|
||||
case playerStatus::DIED:
|
||||
{
|
||||
const int nextPlayerStatus = IsEligibleForHighScore(player->getScore()) ? PLAYER_STATUS_ENTERING_NAME : PLAYER_STATUS_CONTINUE;
|
||||
demo.enabled ? player->setStatusPlaying(PLAYER_STATUS_WAITING) : player->setStatusPlaying(nextPlayerStatus);
|
||||
const playerStatus nextPlayerStatus = IsEligibleForHighScore(player->getScore()) ? playerStatus::ENTERING_NAME : playerStatus::CONTINUE;
|
||||
demo.enabled ? player->setStatusPlaying(playerStatus::WAITING) : player->setStatusPlaying(nextPlayerStatus);
|
||||
// addScoreToScoreBoard(player->getName(), player->getScore());
|
||||
break;
|
||||
}
|
||||
|
||||
case playerStatus::GAME_OVER:
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), scoreboardMode::GAME_OVER);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user