afegit "z-order" per als jugadors
This commit is contained in:
@@ -212,7 +212,7 @@ void Game::updatePlayers()
|
|||||||
// Comprueba la colisión entre el jugador y los globos
|
// Comprueba la colisión entre el jugador y los globos
|
||||||
if (checkPlayerBalloonCollision(player))
|
if (checkPlayerBalloonCollision(player))
|
||||||
{
|
{
|
||||||
killPlayer(player);
|
handlePlayerCollision(player);
|
||||||
|
|
||||||
if (demo_.enabled && allPlayersAreNotPlaying())
|
if (demo_.enabled && allPlayersAreNotPlaying())
|
||||||
{
|
{
|
||||||
@@ -225,6 +225,9 @@ void Game::updatePlayers()
|
|||||||
checkPlayerItemCollision(player);
|
checkPlayerItemCollision(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Organiza la lista de jugadores
|
||||||
|
movePlayersToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja a los jugadores
|
// Dibuja a los jugadores
|
||||||
@@ -899,8 +902,8 @@ void Game::renderPathSprites()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Acciones a realizar cuando el jugador muere
|
// Acciones a realizar cuando el jugador colisiona con un globo
|
||||||
void Game::killPlayer(std::shared_ptr<Player> &player)
|
void Game::handlePlayerCollision(std::shared_ptr<Player> &player)
|
||||||
{
|
{
|
||||||
if (!player->isPlaying() || player->isInvulnerable())
|
if (!player->isPlaying() || player->isInvulnerable())
|
||||||
{
|
{
|
||||||
@@ -925,6 +928,7 @@ void Game::killPlayer(std::shared_ptr<Player> &player)
|
|||||||
screen_->shake();
|
screen_->shake();
|
||||||
playSound("voice_no.wav");
|
playSound("voice_no.wav");
|
||||||
player->setPlayingState(PlayerState::DYING);
|
player->setPlayingState(PlayerState::DYING);
|
||||||
|
players_to_reorder.push_back(player);
|
||||||
if (allPlayersAreNotPlaying())
|
if (allPlayersAreNotPlaying())
|
||||||
{
|
{
|
||||||
// No se puede subir poder de fase si no hay nadie jugando
|
// No se puede subir poder de fase si no hay nadie jugando
|
||||||
@@ -2026,6 +2030,26 @@ void Game::playSound(const std::string &name)
|
|||||||
audio->playSound(name);
|
audio->playSound(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Organiza los jugadores para que los vivos se pinten sobre los muertos
|
||||||
|
void Game::movePlayersToFront()
|
||||||
|
{
|
||||||
|
if (players_to_reorder.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (auto& player : players_to_reorder)
|
||||||
|
{
|
||||||
|
auto it = std::find(players_.begin(), players_.end(), player);
|
||||||
|
if (it != players_.end() && it != players_.begin())
|
||||||
|
{
|
||||||
|
std::shared_ptr<Player> dyingPlayer = *it;
|
||||||
|
players_.erase(it);
|
||||||
|
players_.insert(players_.begin(), dyingPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
players_to_reorder.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// Comprueba los eventos en el modo DEBUG
|
// Comprueba los eventos en el modo DEBUG
|
||||||
void Game::checkDebugEvents(const SDL_Event &event)
|
void Game::checkDebugEvents(const SDL_Event &event)
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ private:
|
|||||||
int menace_current_ = 0; // Nivel de amenaza actual
|
int menace_current_ = 0; // Nivel de amenaza actual
|
||||||
int menace_threshold_ = 0; // Umbral del nivel de amenaza. Si el nivel de amenaza cae por debajo del umbral, se generan más globos. Si el umbral aumenta, aumenta el número de globos
|
int menace_threshold_ = 0; // Umbral del nivel de amenaza. Si el nivel de amenaza cae por debajo del umbral, se generan más globos. Si el umbral aumenta, aumenta el número de globos
|
||||||
GameState state_ = GameState::FADE_IN; // Estado
|
GameState state_ = GameState::FADE_IN; // Estado
|
||||||
|
std::vector<std::shared_ptr<Player>> players_to_reorder;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bool auto_pop_balloons_ = false; // Si es true, incrementa automaticamente los globos explotados
|
bool auto_pop_balloons_ = false; // Si es true, incrementa automaticamente los globos explotados
|
||||||
@@ -162,7 +163,6 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// --- Métodos internos ---
|
// --- Métodos internos ---
|
||||||
|
|
||||||
void update(); // Actualiza el juego
|
void update(); // Actualiza el juego
|
||||||
void render(); // Dibuja el juego
|
void render(); // Dibuja el juego
|
||||||
void checkEvents(); // Comprueba los eventos que hay en cola
|
void checkEvents(); // Comprueba los eventos que hay en cola
|
||||||
@@ -194,7 +194,7 @@ private:
|
|||||||
void renderSmartSprites(); // Pinta los SpriteSmarts activos
|
void renderSmartSprites(); // Pinta los SpriteSmarts activos
|
||||||
void updatePathSprites(); // Actualiza los PathSprites
|
void updatePathSprites(); // Actualiza los PathSprites
|
||||||
void renderPathSprites(); // Pinta los PathSprites activos
|
void renderPathSprites(); // Pinta los PathSprites activos
|
||||||
void killPlayer(std::shared_ptr<Player> &player); // Acciones a realizar cuando el jugador muere
|
void handlePlayerCollision(std::shared_ptr<Player> &player); // Acciones a realizar cuando el jugador colisiona con un globo
|
||||||
void updateTimeStopped(); // Actualiza y comprueba el valor de la variable
|
void updateTimeStopped(); // Actualiza y comprueba el valor de la variable
|
||||||
void updateBackground(); // Actualiza el fondo
|
void updateBackground(); // Actualiza el fondo
|
||||||
void initPaths(); // Inicializa las variables que contienen puntos de ruta para mover objetos
|
void initPaths(); // Inicializa las variables que contienen puntos de ruta para mover objetos
|
||||||
@@ -243,6 +243,7 @@ private:
|
|||||||
void evaluateAndSetMenace(); // Calcula y establece el valor de amenaza en funcion de los globos activos
|
void evaluateAndSetMenace(); // Calcula y establece el valor de amenaza en funcion de los globos activos
|
||||||
void checkAndUpdateBalloonSpeed(); // Actualiza la velocidad de los globos en funcion del poder acumulado de la fase
|
void checkAndUpdateBalloonSpeed(); // Actualiza la velocidad de los globos en funcion del poder acumulado de la fase
|
||||||
void setState(GameState state); // Cambia el estado del juego
|
void setState(GameState state); // Cambia el estado del juego
|
||||||
|
void movePlayersToFront(); // Organiza los jugadores para que los vivos se pinten sobre los muertos
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
void updateRecording(); // Actualiza las variables durante el modo de grabación
|
void updateRecording(); // Actualiza las variables durante el modo de grabación
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user