primera implementació dels estats nous del jugador: playing, continue, waiting
This commit is contained in:
@@ -107,9 +107,11 @@ void Game::init(int playerID)
|
||||
|
||||
// Crea los dos jugadores
|
||||
Player *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 30, playerTextures[0], playerAnimations);
|
||||
player1->setScoreBoardPanel(SCOREBOARD_LEFT_PANEL);
|
||||
players.push_back(player1);
|
||||
|
||||
Player *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 30, playerTextures[1], playerAnimations);
|
||||
player2->setScoreBoardPanel(SCOREBOARD_RIGHT_PANEL);
|
||||
players.push_back(player2);
|
||||
|
||||
// Cambia el estado del jugador seleccionado
|
||||
@@ -931,22 +933,18 @@ void Game::updatePlayers()
|
||||
{
|
||||
for (auto player : players)
|
||||
{
|
||||
if (player->isPlaying())
|
||||
{
|
||||
player->update();
|
||||
player->update();
|
||||
|
||||
// Comprueba la colisión entre el jugador y los globos
|
||||
if (player->isPlaying())
|
||||
{ // Comprueba la colisión entre el jugador y los globos
|
||||
if (checkPlayerBalloonCollision(player))
|
||||
{
|
||||
if (player->isPlaying())
|
||||
{
|
||||
killPlayer(player);
|
||||
killPlayer(player);
|
||||
|
||||
if (demo.enabled && allPlayersAreWaiting())
|
||||
{
|
||||
fade->setType(FADE_RANDOM_SQUARE);
|
||||
fade->activate();
|
||||
}
|
||||
if (demo.enabled && allPlayersAreWaiting())
|
||||
{
|
||||
fade->setType(FADE_RANDOM_SQUARE);
|
||||
fade->activate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1968,6 +1966,7 @@ void Game::update()
|
||||
updatePlayers();
|
||||
|
||||
// Actualiza el marcador
|
||||
checkPlayersStatus();
|
||||
updateScoreboard();
|
||||
|
||||
// Actualiza el fondo
|
||||
@@ -2101,9 +2100,9 @@ void Game::render()
|
||||
renderSeparator();
|
||||
|
||||
#ifdef DEBUG
|
||||
//text->write(0, 0, "P1 ALIVE: " + boolToString(players[0]->isAlive()));
|
||||
//text->write(0, 10, "P2 ALIVE: " + boolToString(players[1]->isAlive()));
|
||||
//text->write(0, 20, "ALL DEAD: " + boolToString(allPlayersAreWaiting()));
|
||||
// text->write(0, 0, "P1 ALIVE: " + boolToString(players[0]->isAlive()));
|
||||
// text->write(0, 10, "P2 ALIVE: " + boolToString(players[1]->isAlive()));
|
||||
// text->write(0, 20, "ALL DEAD: " + boolToString(allPlayersAreWaiting()));
|
||||
#endif
|
||||
|
||||
// Dibuja el fade
|
||||
@@ -2631,10 +2630,10 @@ void Game::updateHelper()
|
||||
// Comprueba si todos los jugadores han terminado de jugar
|
||||
bool Game::allPlayersAreWaiting()
|
||||
{
|
||||
bool success = false;
|
||||
bool success = true;
|
||||
for (auto player : players)
|
||||
{
|
||||
success |= player->isWaiting();
|
||||
success &= player->isWaiting();
|
||||
}
|
||||
|
||||
return success;
|
||||
@@ -2840,4 +2839,30 @@ void Game::addScoreToScoreBoard(std::string name, int score)
|
||||
ManageHiScoreTable *m = new ManageHiScoreTable(&options->game.hiScoreTable);
|
||||
m->add(entry);
|
||||
delete m;
|
||||
}
|
||||
|
||||
// Comprueba el estado de los jugadores
|
||||
void Game::checkPlayersStatus()
|
||||
{
|
||||
for (auto player : players)
|
||||
{
|
||||
switch (player->getStatusPlaying())
|
||||
{
|
||||
case PLAYER_STATUS_PLAYING:
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), SCOREBOARD_MODE_SCORE);
|
||||
break;
|
||||
|
||||
case PLAYER_STATUS_CONTINUE:
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), SCOREBOARD_MODE_CONTINUE);
|
||||
scoreboard->setContinue1(player->getContinueCounter());
|
||||
break;
|
||||
|
||||
case PLAYER_STATUS_WAITING:
|
||||
scoreboard->setMode(player->getScoreBoardPanel(), SCOREBOARD_MODE_GAME_OVER);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user