Refet el spritesheet del jugador i el fitxer d'animacions
Afegits nous estats per al jugador: RECOIL
This commit is contained in:
@@ -1431,37 +1431,65 @@ void Game::handleFireInput(const std::shared_ptr<Player> &player, BulletType bul
|
||||
{
|
||||
if (player->canFire())
|
||||
{
|
||||
player->setInput(bulletType == BulletType::UP ? InputAction::FIRE_CENTER : bulletType == BulletType::LEFT ? InputAction::FIRE_LEFT
|
||||
: InputAction::FIRE_RIGHT);
|
||||
switch (bulletType)
|
||||
{
|
||||
case BulletType::UP:
|
||||
player->setInput(InputAction::FIRE_CENTER);
|
||||
break;
|
||||
case BulletType::LEFT:
|
||||
player->setInput(InputAction::FIRE_LEFT);
|
||||
break;
|
||||
case BulletType::RIGHT:
|
||||
player->setInput(InputAction::FIRE_RIGHT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 6, player->getPosY() + (player->getHeight() / 2), bulletType, player->isPowerUp(), player->getId());
|
||||
playSound("bullet.wav");
|
||||
|
||||
// Establece un tiempo de espera para el próximo disparo.
|
||||
const int cooldown = player->isPowerUp() ? 5 : Options::settings.autofire ? 10
|
||||
: 7;
|
||||
player->setFireCooldown(cooldown);
|
||||
constexpr int POWERUP_COOLDOWN = 5;
|
||||
constexpr int AUTOFIRE_COOLDOWN = 10;
|
||||
constexpr int NORMAL_COOLDOWN = 7;
|
||||
|
||||
int cant_fire_counter;
|
||||
if (player->isPowerUp())
|
||||
{
|
||||
cant_fire_counter = POWERUP_COOLDOWN;
|
||||
}
|
||||
else if (Options::settings.autofire)
|
||||
{
|
||||
cant_fire_counter = AUTOFIRE_COOLDOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
cant_fire_counter = NORMAL_COOLDOWN;
|
||||
}
|
||||
|
||||
player->setCantFireCounter(cant_fire_counter);
|
||||
}
|
||||
}
|
||||
|
||||
// Gestiona las entradas de todos los jugadores en el modo normal (fuera del modo demo).
|
||||
void Game::handlePlayersInput()
|
||||
{
|
||||
for (const auto &player : players_)
|
||||
for (const auto &PLAYER : players_)
|
||||
{
|
||||
if (player->isPlaying())
|
||||
if (PLAYER->isPlaying())
|
||||
{
|
||||
// Maneja el input de los jugadores en modo normal.
|
||||
handleNormalPlayerInput(player);
|
||||
handleNormalPlayerInput(PLAYER);
|
||||
}
|
||||
else if (player->isContinue() || player->isWaiting())
|
||||
else if (PLAYER->isContinue() || PLAYER->isWaiting())
|
||||
{
|
||||
// Gestiona la continuación del jugador.
|
||||
handlePlayerContinue(player);
|
||||
handlePlayerContinue(PLAYER);
|
||||
}
|
||||
else if (player->isEnteringName() || player->isEnteringNameGameCompleted() || player->isShowingName())
|
||||
else if (PLAYER->isEnteringName() || PLAYER->isEnteringNameGameCompleted() || PLAYER->isShowingName())
|
||||
{
|
||||
// Gestiona la introducción del nombre del jugador.
|
||||
handleNameInput(player);
|
||||
handleNameInput(PLAYER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1469,17 +1497,17 @@ void Game::handlePlayersInput()
|
||||
// Maneja las entradas de movimiento y disparo para un jugador en modo normal.
|
||||
void Game::handleNormalPlayerInput(const std::shared_ptr<Player> &player)
|
||||
{
|
||||
const auto &controller = Options::controllers.at(player->getController());
|
||||
const bool autofire = player->isPowerUp() || Options::settings.autofire;
|
||||
const auto &CONTROLLER = Options::controllers.at(player->getController());
|
||||
const bool AUTOFIRE = player->isPowerUp() || Options::settings.autofire;
|
||||
|
||||
if (input_->checkInput(InputAction::LEFT, INPUT_ALLOW_REPEAT, controller.type, controller.index))
|
||||
if (input_->checkInput(InputAction::LEFT, INPUT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index))
|
||||
{
|
||||
player->setInput(InputAction::LEFT);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.left = 1;
|
||||
#endif
|
||||
}
|
||||
else if (input_->checkInput(InputAction::RIGHT, INPUT_ALLOW_REPEAT, controller.type, controller.index))
|
||||
else if (input_->checkInput(InputAction::RIGHT, INPUT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index))
|
||||
{
|
||||
player->setInput(InputAction::RIGHT);
|
||||
#ifdef RECORDING
|
||||
@@ -1494,7 +1522,7 @@ void Game::handleNormalPlayerInput(const std::shared_ptr<Player> &player)
|
||||
#endif
|
||||
}
|
||||
|
||||
handleFireInputs(player, autofire, player->getController()); // Verifica y maneja todas las posibles entradas de disparo.
|
||||
handleFireInputs(player, AUTOFIRE, player->getController()); // Verifica y maneja todas las posibles entradas de disparo.
|
||||
}
|
||||
|
||||
// Procesa las entradas de disparo del jugador, permitiendo disparos automáticos si está habilitado.
|
||||
@@ -1987,9 +2015,11 @@ void Game::checkDebugEvents(const SDL_Event &event)
|
||||
balloon_manager_->createPowerBall();
|
||||
break;
|
||||
}
|
||||
case SDLK_2: // Crea dos globos gordos
|
||||
case SDLK_2: // Activa o desactiva la aparición de globos
|
||||
{
|
||||
balloon_manager_->createTwoBigBalloons();
|
||||
static bool deploy_balloons = true;
|
||||
deploy_balloons = !deploy_balloons;
|
||||
balloon_manager_->enableBalloonDeployment(deploy_balloons);
|
||||
break;
|
||||
}
|
||||
case SDLK_3: // Activa el modo para pasar el juego automaticamente
|
||||
@@ -2001,7 +2031,7 @@ void Game::checkDebugEvents(const SDL_Event &event)
|
||||
balloon_manager_->destroyAllBalloons();
|
||||
playSound("power_ball_explosion.wav");
|
||||
}
|
||||
balloon_manager_->setDeployBalloons(!auto_pop_balloons_);
|
||||
balloon_manager_->enableBalloonDeployment(!auto_pop_balloons_);
|
||||
break;
|
||||
}
|
||||
case SDLK_4: // Suelta un item
|
||||
|
||||
Reference in New Issue
Block a user