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:
@@ -229,12 +229,6 @@ void Balloon::move()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deshabilita el globo
|
|
||||||
void Balloon::disable() { enabled_ = false; }
|
|
||||||
|
|
||||||
// Explosiona el globo
|
|
||||||
void Balloon::pop() { disable(); }
|
|
||||||
|
|
||||||
// Actualiza al globo a su posicion, animación y controla los contadores
|
// Actualiza al globo a su posicion, animación y controla los contadores
|
||||||
void Balloon::update()
|
void Balloon::update()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -170,12 +170,6 @@ public:
|
|||||||
// Actualiza la posición y estados del globo
|
// Actualiza la posición y estados del globo
|
||||||
void move();
|
void move();
|
||||||
|
|
||||||
// Deshabilita el globo y pone a cero todos los valores
|
|
||||||
void disable();
|
|
||||||
|
|
||||||
// Explosiona el globo
|
|
||||||
void pop();
|
|
||||||
|
|
||||||
// Actualiza al globo a su posicion, animación y controla los contadores
|
// Actualiza al globo a su posicion, animación y controla los contadores
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
@@ -215,4 +209,5 @@ public:
|
|||||||
void setSpeed(float speed) { speed_ = speed; }
|
void setSpeed(float speed) { speed_ = speed; }
|
||||||
void setInvulnerable(bool value) { invulnerable_ = value; }
|
void setInvulnerable(bool value) { invulnerable_ = value; }
|
||||||
void setSound(bool value) { sound_enabled_ = value; }
|
void setSound(bool value) { sound_enabled_ = value; }
|
||||||
|
void disable() { enabled_ = false; }
|
||||||
};
|
};
|
||||||
@@ -258,7 +258,7 @@ int BalloonManager::popBalloon(std::shared_ptr<Balloon> balloon)
|
|||||||
|
|
||||||
// Agrega la explosión y elimina el globo
|
// Agrega la explosión y elimina el globo
|
||||||
explosions_->add(balloon->getPosX(), balloon->getPosY(), static_cast<int>(balloon->getSize()));
|
explosions_->add(balloon->getPosX(), balloon->getPosY(), static_cast<int>(balloon->getSize()));
|
||||||
balloon->pop();
|
balloon->disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
return score;
|
return score;
|
||||||
@@ -294,7 +294,7 @@ int BalloonManager::destroyBalloon(std::shared_ptr<Balloon> &balloon)
|
|||||||
|
|
||||||
// Destruye el globo
|
// Destruye el globo
|
||||||
explosions_->add(balloon->getPosX(), balloon->getPosY(), static_cast<int>(balloon->getSize()));
|
explosions_->add(balloon->getPosX(), balloon->getPosY(), static_cast<int>(balloon->getSize()));
|
||||||
balloon->pop();
|
balloon->disable();
|
||||||
|
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,8 +255,6 @@ void Game::renderPlayers()
|
|||||||
|
|
||||||
// Comprueba si hay cambio de fase y actualiza las variables
|
// Comprueba si hay cambio de fase y actualiza las variables
|
||||||
void Game::updateStage()
|
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)
|
||||||
{
|
{
|
||||||
@@ -285,7 +283,6 @@ void Game::updateStage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza el estado de fin de la partida
|
// Actualiza el estado de fin de la partida
|
||||||
void Game::updateGameStateGameOver()
|
void Game::updateGameStateGameOver()
|
||||||
@@ -858,7 +855,8 @@ void Game::renderPathSprites()
|
|||||||
void Game::killPlayer(std::shared_ptr<Player> &player)
|
void Game::killPlayer(std::shared_ptr<Player> &player)
|
||||||
{
|
{
|
||||||
if (!player->isPlaying() || player->isInvulnerable())
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -874,12 +872,16 @@ void Game::killPlayer(std::shared_ptr<Player> &player)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Si no tiene cafes, muere
|
// Si no tiene cafes, muere
|
||||||
// pauseMusic();
|
|
||||||
balloon_manager_->stopAllBalloons();
|
balloon_manager_->stopAllBalloons();
|
||||||
JA_PlaySound(Resource::get()->getSound("player_collision.wav"));
|
JA_PlaySound(Resource::get()->getSound("player_collision.wav"));
|
||||||
screen_->shake();
|
screen_->shake();
|
||||||
JA_PlaySound(Resource::get()->getSound("voice_no.wav"));
|
JA_PlaySound(Resource::get()->getSound("voice_no.wav"));
|
||||||
player->setPlayingState(PlayerState::DYING);
|
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_++;
|
counter_++;
|
||||||
|
|
||||||
updateDemo();
|
updateDemo();
|
||||||
|
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
updateRecording();
|
updateRecording();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "texture.h" // Para Texture
|
#include "texture.h" // Para Texture
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "jail_audio.h"
|
#include "jail_audio.h"
|
||||||
|
#include "stage.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Player::Player(int id, float x, int y, bool demo, SDL_Rect &play_area, std::vector<std::shared_ptr<Texture>> texture, const std::vector<std::vector<std::string>> &animations)
|
Player::Player(int id, float x, int y, bool demo, SDL_Rect &play_area, std::vector<std::shared_ptr<Texture>> texture, const std::vector<std::vector<std::string>> &animations)
|
||||||
@@ -503,6 +504,7 @@ void Player::setPlayingState(PlayerState state)
|
|||||||
init();
|
init();
|
||||||
playing_state_ = PlayerState::PLAYING;
|
playing_state_ = PlayerState::PLAYING;
|
||||||
setScoreboardMode(ScoreboardMode::SCORE);
|
setScoreboardMode(ScoreboardMode::SCORE);
|
||||||
|
Stage::power_can_be_added = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PlayerState::CONTINUE:
|
case PlayerState::CONTINUE:
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace Stage
|
|||||||
int power = 0; // Poder acumulado en la fase
|
int power = 0; // Poder acumulado en la fase
|
||||||
int total_power = 0; // Poder total necesario para completar el juego
|
int total_power = 0; // Poder total necesario para completar el juego
|
||||||
int number = 0; // Fase actual
|
int number = 0; // Fase actual
|
||||||
|
bool power_can_be_added = true; // Habilita la recolecta de poder
|
||||||
|
|
||||||
// Devuelve una fase
|
// Devuelve una fase
|
||||||
Stage get(int index) { return stages.at(std::min(9, index)); }
|
Stage get(int index) { return stages.at(std::min(9, index)); }
|
||||||
@@ -34,8 +35,11 @@ namespace Stage
|
|||||||
|
|
||||||
// Añade poder
|
// Añade poder
|
||||||
void addPower(int amount)
|
void addPower(int amount)
|
||||||
|
{
|
||||||
|
if (power_can_be_added)
|
||||||
{
|
{
|
||||||
power += amount;
|
power += amount;
|
||||||
total_power += amount;
|
total_power += amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ namespace Stage
|
|||||||
extern int power; // Poder acumulado en la fase
|
extern int power; // Poder acumulado en la fase
|
||||||
extern int total_power; // Poder total necesario para completar el juego
|
extern int total_power; // Poder total necesario para completar el juego
|
||||||
extern int number; // Fase actual
|
extern int number; // Fase actual
|
||||||
|
extern bool power_can_be_added; // Indica si se puede añadir poder a la fase
|
||||||
|
|
||||||
// Devuelve una fase
|
// Devuelve una fase
|
||||||
Stage get(int index);
|
Stage get(int index);
|
||||||
|
|||||||
Reference in New Issue
Block a user