Afegit un lock per evitar que es puga incrementar el poder de la fase

Es necesita almenys un jugador viu per a poder incrementar el poder de la fase
This commit is contained in:
2025-01-04 14:09:10 +01:00
parent 7b8f16610a
commit 81ee352553
7 changed files with 43 additions and 46 deletions

View File

@@ -256,32 +256,29 @@ void Game::renderPlayers()
// Comprueba si hay cambio de fase y actualiza las variables
void Game::updateStage()
{
if (state_ == GameState::PLAYING)
if (Stage::power >= Stage::get(Stage::number).power_to_complete)
{
if (Stage::power >= Stage::get(Stage::number).power_to_complete)
{
// Cambio de fase
Stage::power = Stage::get(Stage::number).power_to_complete - Stage::power;
++Stage::number;
JA_PlaySound(Resource::get()->getSound("stage_change.wav"));
balloon_manager_->resetBalloonSpeed();
screen_->flash(flash_color, 3);
screen_->shake();
// Cambio de fase
Stage::power = Stage::get(Stage::number).power_to_complete - Stage::power;
++Stage::number;
JA_PlaySound(Resource::get()->getSound("stage_change.wav"));
balloon_manager_->resetBalloonSpeed();
screen_->flash(flash_color, 3);
screen_->shake();
// Escribe el texto por pantalla
if (Stage::number < 10)
// Escribe el texto por pantalla
if (Stage::number < 10)
{
std::vector<Path> paths = {paths_.at(2), paths_.at(3)};
if (Stage::number == 9)
{
std::vector<Path> paths = {paths_.at(2), paths_.at(3)};
if (Stage::number == 9)
{
createMessage(paths, Resource::get()->getTexture("game_text_last_stage"));
}
else
{
auto text = Resource::get()->getText("04b_25_2x");
const std::string caption = std::to_string(10 - Stage::number) + lang::getText(38);
createMessage(paths, text->writeToTexture(caption, 1, -4));
}
createMessage(paths, Resource::get()->getTexture("game_text_last_stage"));
}
else
{
auto text = Resource::get()->getText("04b_25_2x");
const std::string caption = std::to_string(10 - Stage::number) + lang::getText(38);
createMessage(paths, text->writeToTexture(caption, 1, -4));
}
}
}
@@ -858,7 +855,8 @@ void Game::renderPathSprites()
void Game::killPlayer(std::shared_ptr<Player> &player)
{
if (!player->isPlaying() || player->isInvulnerable())
{ // Si no está jugando o tiene inmunidad, no hace nada
{
// Si no está jugando o tiene inmunidad, no hace nada
return;
}
@@ -874,12 +872,16 @@ void Game::killPlayer(std::shared_ptr<Player> &player)
else
{
// Si no tiene cafes, muere
// pauseMusic();
balloon_manager_->stopAllBalloons();
JA_PlaySound(Resource::get()->getSound("player_collision.wav"));
screen_->shake();
JA_PlaySound(Resource::get()->getSound("voice_no.wav"));
player->setPlayingState(PlayerState::DYING);
if (allPlayersAreNotPlaying())
{
// No se puede subir poder de fase si no hay nadie jugando
Stage::power_can_be_added = false;
}
}
}
@@ -919,7 +921,6 @@ void Game::update()
counter_++;
updateDemo();
#ifdef RECORDING
updateRecording();
#endif