Els panels dels marcadors ja passen a game over sense pasar per waiting un frame gracies a una parafernalia que he montat
This commit is contained in:
@@ -942,16 +942,6 @@ void Game::updateStage()
|
|||||||
// Actualiza el estado de fin de la partida
|
// Actualiza el estado de fin de la partida
|
||||||
void Game::updateGameOver()
|
void Game::updateGameOver()
|
||||||
{
|
{
|
||||||
// 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
|
// Si todos estan en estado de Game Over
|
||||||
if (allPlayersAreGameOver())
|
if (allPlayersAreGameOver())
|
||||||
{
|
{
|
||||||
@@ -1895,7 +1885,7 @@ void Game::update()
|
|||||||
updatePlayers();
|
updatePlayers();
|
||||||
|
|
||||||
// Actualiza el marcador
|
// Actualiza el marcador
|
||||||
// checkPlayersStatusPlaying();
|
checkPlayersStatusPlaying();
|
||||||
updateScoreboard();
|
updateScoreboard();
|
||||||
|
|
||||||
// Actualiza el fondo
|
// Actualiza el fondo
|
||||||
@@ -2579,12 +2569,12 @@ void Game::updateHelper()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si todos los jugadores han terminado de jugar
|
// Comprueba si todos los jugadores han terminado de jugar
|
||||||
bool Game::allPlayersAreWaiting()
|
bool Game::allPlayersAreWaitingOrGameOver()
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
for (auto player : players)
|
for (auto player : players)
|
||||||
{
|
{
|
||||||
success &= player->isWaiting();
|
success &= player->isWaiting() || player->isGameOver();
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
@@ -2828,65 +2818,39 @@ void Game::addScoreToScoreBoard(std::string name, int score)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el estado de los jugadores
|
// Comprueba el estado de los jugadores
|
||||||
/*void Game::checkPlayersStatusPlaying()
|
void Game::checkPlayersStatusPlaying()
|
||||||
{
|
{
|
||||||
if (demo.enabled)
|
if (demo.enabled)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto player : players)
|
// Comprueba si todos los jugadores estan esperando
|
||||||
|
if (allPlayersAreWaitingOrGameOver())
|
||||||
{
|
{
|
||||||
switch (player->getStatusPlaying())
|
// Entonces los pone en estado de Game Over
|
||||||
|
for (auto player : players)
|
||||||
{
|
{
|
||||||
case playerStatus::PLAYING:
|
player->setStatusPlaying(playerStatus::GAME_OVER);
|
||||||
{
|
|
||||||
scoreboard->setMode(player->getScoreBoardPanel(), scoreboardMode::SCORE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case playerStatus::CONTINUE:
|
|
||||||
{
|
|
||||||
scoreboard->setMode(player->getScoreBoardPanel(), scoreboardMode::CONTINUE);
|
|
||||||
scoreboard->setContinue(player->getScoreBoardPanel(), player->getContinueCounter());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case playerStatus::WAITING:
|
|
||||||
{
|
|
||||||
scoreboard->setMode(player->getScoreBoardPanel(), scoreboardMode::WAITING);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 playerStatus::DYING:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case playerStatus::DIED:
|
|
||||||
{
|
|
||||||
const playerStatus nextPlayerStatus = IsEligibleForHighScore(player->getScore()) ? playerStatus::ENTERING_NAME : playerStatus::CONTINUE;
|
|
||||||
demo.enabled ? player->setStatusPlaying(playerStatus::WAITING) : player->setStatusPlaying(nextPlayerStatus);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case playerStatus::GAME_OVER:
|
|
||||||
{
|
|
||||||
scoreboard->setMode(player->getScoreBoardPanel(), scoreboardMode::GAME_OVER);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
// Saca del estado de GAME OVER al primer jugador si el segundo está activo
|
||||||
|
const bool a1 = players[0]->isGameOver();
|
||||||
|
const bool b1 = !players[1]->isGameOver() && !players[1]->isWaiting();
|
||||||
|
if (a1 && b1)
|
||||||
|
{
|
||||||
|
players[0]->setStatusPlaying(playerStatus::WAITING);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Saca del estado de GAME OVER al segundo jugador si el primero está activo
|
||||||
|
const bool a2 = players[1]->isGameOver();
|
||||||
|
const bool b2 = !players[0]->isGameOver() && !players[0]->isWaiting();
|
||||||
|
if (a2 && b2)
|
||||||
|
{
|
||||||
|
players[1]->setStatusPlaying(playerStatus::WAITING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Obtiene un jugador a partir de su "id"
|
// Obtiene un jugador a partir de su "id"
|
||||||
Player *Game::getPlayer(int id)
|
Player *Game::getPlayer(int id)
|
||||||
|
|||||||
@@ -412,7 +412,7 @@ private:
|
|||||||
void updateHelper();
|
void updateHelper();
|
||||||
|
|
||||||
// Comprueba si todos los jugadores han terminado de jugar
|
// Comprueba si todos los jugadores han terminado de jugar
|
||||||
bool allPlayersAreWaiting();
|
bool allPlayersAreWaitingOrGameOver();
|
||||||
|
|
||||||
// Comprueba si todos los jugadores han terminado de jugar
|
// Comprueba si todos los jugadores han terminado de jugar
|
||||||
bool allPlayersAreGameOver();
|
bool allPlayersAreGameOver();
|
||||||
@@ -445,7 +445,7 @@ private:
|
|||||||
void addScoreToScoreBoard(std::string name, int score);
|
void addScoreToScoreBoard(std::string name, int score);
|
||||||
|
|
||||||
// Comprueba el estado de juego de los jugadores
|
// Comprueba el estado de juego de los jugadores
|
||||||
//void checkPlayersStatusPlaying();
|
void checkPlayersStatusPlaying();
|
||||||
|
|
||||||
// Obtiene un jugador a partir de su "id"
|
// Obtiene un jugador a partir de su "id"
|
||||||
Player *getPlayer(int id);
|
Player *getPlayer(int id);
|
||||||
|
|||||||
@@ -724,7 +724,7 @@ void Player::decContinueCounter()
|
|||||||
continueCounter--;
|
continueCounter--;
|
||||||
if (continueCounter < 0)
|
if (continueCounter < 0)
|
||||||
{
|
{
|
||||||
setStatusPlaying(playerStatus::WAITING);
|
setStatusPlaying(playerStatus::GAME_OVER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,19 +15,19 @@ Scoreboard *Scoreboard::scoreboard = nullptr;
|
|||||||
// [SINGLETON] Crearemos el objeto scoreboard con esta función estática
|
// [SINGLETON] Crearemos el objeto scoreboard con esta función estática
|
||||||
void Scoreboard::init(SDL_Renderer *renderer)
|
void Scoreboard::init(SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
Scoreboard::scoreboard = new Scoreboard(renderer);
|
Scoreboard::scoreboard = new Scoreboard(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// [SINGLETON] Destruiremos el objeto scoreboard con esta función estática
|
// [SINGLETON] Destruiremos el objeto scoreboard con esta función estática
|
||||||
void Scoreboard::destroy()
|
void Scoreboard::destroy()
|
||||||
{
|
{
|
||||||
delete Scoreboard::scoreboard;
|
delete Scoreboard::scoreboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [SINGLETON] Con este método obtenemos el objeto scoreboard y podemos trabajar con él
|
// [SINGLETON] Con este método obtenemos el objeto scoreboard y podemos trabajar con él
|
||||||
Scoreboard *Scoreboard::get()
|
Scoreboard *Scoreboard::get()
|
||||||
{
|
{
|
||||||
return Scoreboard::scoreboard;
|
return Scoreboard::scoreboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -263,7 +263,7 @@ void Scoreboard::fillPanelTextures()
|
|||||||
switch (panel[i].mode)
|
switch (panel[i].mode)
|
||||||
{
|
{
|
||||||
case scoreboardMode::SCORE:
|
case scoreboardMode::SCORE:
|
||||||
{
|
{
|
||||||
// SCORE
|
// SCORE
|
||||||
textScoreBoard->writeCentered(slot4_1.x, slot4_1.y, name[i]);
|
textScoreBoard->writeCentered(slot4_1.x, slot4_1.y, name[i]);
|
||||||
textScoreBoard->writeCentered(slot4_2.x, slot4_2.y, updateScoreText(score[i]));
|
textScoreBoard->writeCentered(slot4_2.x, slot4_2.y, updateScoreText(score[i]));
|
||||||
@@ -306,7 +306,13 @@ void Scoreboard::fillPanelTextures()
|
|||||||
{
|
{
|
||||||
// GAME OVER
|
// GAME OVER
|
||||||
textScoreBoard->writeCentered(slot4_1.x, slot4_1.y + 4, lang::getText(102));
|
textScoreBoard->writeCentered(slot4_1.x, slot4_1.y + 4, lang::getText(102));
|
||||||
textScoreBoard->writeCentered(slot4_3.x, slot4_3.y + 4, lang::getText(114));
|
|
||||||
|
// PLEASE WAIT
|
||||||
|
if (counter % 10 < 8)
|
||||||
|
{
|
||||||
|
textScoreBoard->writeCentered(slot4_3.x, slot4_3.y - 2, lang::getText(114));
|
||||||
|
textScoreBoard->writeCentered(slot4_4.x, slot4_4.y - 2, lang::getText(115));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user