canvi de pc
This commit is contained in:
@@ -169,7 +169,7 @@ class Player {
|
||||
static constexpr float BASE_SPEED = 1.5F; // Velocidad base del jugador
|
||||
static constexpr int COOLING_DURATION = 50;
|
||||
static constexpr int COOLING_COMPLETE = 0;
|
||||
static constexpr int WAITING_COUNTER = 1000;
|
||||
static constexpr int WAITING_COUNTER = 300;
|
||||
|
||||
// --- Objetos y punteros ---
|
||||
std::unique_ptr<AnimatedSprite> player_sprite_; // Sprite para dibujar el jugador
|
||||
|
||||
@@ -231,7 +231,7 @@ void Game::updatePlayers() {
|
||||
}
|
||||
|
||||
// Organiza la lista de jugadores
|
||||
movePlayersToFront();
|
||||
sortPlayersByZOrder();
|
||||
}
|
||||
|
||||
// Dibuja a los jugadores
|
||||
@@ -858,7 +858,7 @@ void Game::handlePlayerCollision(std::shared_ptr<Player> &player, std::shared_pt
|
||||
screen_->shake();
|
||||
playSound("voice_no.wav");
|
||||
player->setPlayingState(Player::State::ROLLING);
|
||||
players_to_reorder_.push_back(player);
|
||||
sendPlayerToTheBack(player);
|
||||
if (allPlayersAreNotPlaying()) {
|
||||
Stage::power_can_be_added = false; // No se puede subir poder de fase si no hay nadie jugando
|
||||
}
|
||||
@@ -1418,6 +1418,7 @@ void Game::handlePlayerContinue(const std::shared_ptr<Player> &player) {
|
||||
} else if (player->isWaiting()) {
|
||||
player->setPlayingState(Player::State::ENTERING_SCREEN);
|
||||
}
|
||||
sendPlayerToTheFront(player);
|
||||
}
|
||||
|
||||
// Disminuye el contador de continuación si se presiona cualquier botón de disparo.
|
||||
@@ -1603,7 +1604,10 @@ void Game::initPlayers(int player_id) {
|
||||
getPlayer(1)->setPlayingState(demo_.enabled ? Player::State::PLAYING : Player::State::ENTERING_SCREEN);
|
||||
getPlayer(2)->setPlayingState(demo_.enabled ? Player::State::PLAYING : Player::State::ENTERING_SCREEN);
|
||||
} else {
|
||||
getPlayer(player_id)->setPlayingState(demo_.enabled ? Player::State::PLAYING : Player::State::ENTERING_SCREEN);
|
||||
// Activa el jugador elegido
|
||||
auto player = getPlayer(player_id);
|
||||
player->setPlayingState(demo_.enabled ? Player::State::PLAYING : Player::State::ENTERING_SCREEN);
|
||||
sendPlayerToTheFront(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1808,20 +1812,32 @@ void Game::playSound(const std::string &name) const {
|
||||
}
|
||||
|
||||
// Organiza los jugadores para que los vivos se pinten sobre los muertos
|
||||
void Game::movePlayersToFront() {
|
||||
if (players_to_reorder_.empty()) {
|
||||
return;
|
||||
void Game::sortPlayersByZOrder() {
|
||||
// Procesar jugadores que van al fondo (se dibujan primero)
|
||||
if (!players_to_put_at_back_.empty()) {
|
||||
for (auto &player : players_to_put_at_back_) {
|
||||
auto it = std::find(players_.begin(), players_.end(), player);
|
||||
if (it != players_.end() && it != players_.begin()) {
|
||||
std::shared_ptr<Player> dying_player = *it;
|
||||
players_.erase(it);
|
||||
players_.insert(players_.begin(), dying_player);
|
||||
}
|
||||
}
|
||||
players_to_put_at_back_.clear();
|
||||
}
|
||||
|
||||
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> dying_player = *it;
|
||||
players_.erase(it);
|
||||
players_.insert(players_.begin(), dying_player);
|
||||
// Procesar jugadores que van al frente (se dibujan últimos)
|
||||
if (!players_to_put_at_front_.empty()) {
|
||||
for (auto &player : players_to_put_at_front_) {
|
||||
auto it = std::find(players_.begin(), players_.end(), player);
|
||||
if (it != players_.end() && it != players_.end() - 1) {
|
||||
std::shared_ptr<Player> front_player = *it;
|
||||
players_.erase(it);
|
||||
players_.push_back(front_player);
|
||||
}
|
||||
}
|
||||
players_to_put_at_front_.clear();
|
||||
}
|
||||
players_to_reorder_.clear();
|
||||
}
|
||||
|
||||
// Comprueba si está activo el menu de servicio para poner el juego en pausa
|
||||
@@ -1860,6 +1876,16 @@ void Game::putHitOnScreen(SDL_FPoint position) {
|
||||
hit_.disable();
|
||||
}
|
||||
|
||||
// Mueve el jugador para pintarlo al fondo de la lista de jugadores
|
||||
void Game::sendPlayerToTheBack(const std::shared_ptr<Player> &player) {
|
||||
players_to_put_at_back_.push_back(player);
|
||||
}
|
||||
|
||||
// Mueve el jugador para pintarlo el primero de la lista de jugadores
|
||||
void Game::sendPlayerToTheFront(const std::shared_ptr<Player> &player) {
|
||||
players_to_put_at_front_.push_back(player);
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Comprueba los eventos en el modo DEBUG
|
||||
void Game::checkDebugEvents(const SDL_Event &event) {
|
||||
|
||||
@@ -147,7 +147,8 @@ class Game {
|
||||
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
|
||||
State state_ = State::FADE_IN; // Estado
|
||||
std::vector<std::shared_ptr<Player>> players_to_reorder_;
|
||||
std::vector<std::shared_ptr<Player>> players_to_put_at_back_;
|
||||
std::vector<std::shared_ptr<Player>> players_to_put_at_front_;
|
||||
Hit hit_; // Para representar colisiones en pantalla
|
||||
|
||||
#ifdef _DEBUG
|
||||
@@ -176,7 +177,7 @@ class Game {
|
||||
void initPlayers(int player_id); // Inicializa los datos de los jugadores
|
||||
void updatePlayers(); // Actualiza las variables y estados de los jugadores
|
||||
void renderPlayers(); // Renderiza todos los jugadores en pantalla
|
||||
void movePlayersToFront(); // Reorganiza el orden de dibujado de jugadores
|
||||
void sortPlayersByZOrder(); // Reorganiza el orden de dibujado de jugadores
|
||||
auto getPlayer(int id) -> std::shared_ptr<Player>; // Obtiene un jugador por su identificador
|
||||
static auto getController(int player_id) -> int; // Obtiene el controlador asignado a un jugador
|
||||
|
||||
@@ -293,8 +294,10 @@ class Game {
|
||||
// --- Utilidades y servicios ---
|
||||
void checkServiceMenu(); // Verifica si el menú de servicio está activo
|
||||
|
||||
void renderHit(); // Dibuja el golpe que recibe el jugador al impactarle un globo
|
||||
void putHitOnScreen(SDL_FPoint position); // Coloca el Hit en pantalla obligando a hacer un renderizado
|
||||
void renderHit(); // Dibuja el golpe que recibe el jugador al impactarle un globo
|
||||
void putHitOnScreen(SDL_FPoint position); // Coloca el Hit en pantalla obligando a hacer un renderizado
|
||||
void sendPlayerToTheBack(const std::shared_ptr<Player> &player); // Mueve el jugador para pintarlo al fondo de la lista de jugadores
|
||||
void sendPlayerToTheFront(const std::shared_ptr<Player> &player); // Mueve el jugador para pintarlo el primero de la lista de jugadores
|
||||
|
||||
// SISTEMA DE GRABACIÓN (CONDICIONAL)
|
||||
#ifdef RECORDING
|
||||
|
||||
Reference in New Issue
Block a user