Si no poses cap nom, tria un nom de jailer al azar

This commit is contained in:
2025-03-10 19:59:21 +01:00
parent e0c10f83d6
commit c88a277cba
6 changed files with 46 additions and 36 deletions

View File

@@ -149,6 +149,11 @@ void Player::setInputEnteringName(InputType input)
break;
case InputType::START:
last_enter_name_ = getRecordName();
if (last_enter_name_.empty())
{
const std::array<std::string, 8> NAMES = {"BAL1", "TABE", "DOC", "MON", "SAM1", "JORDI", "JDES", "PEPE"};
last_enter_name_ = NAMES.at(rand() % NAMES.size());
}
break;
default:
break;
@@ -166,9 +171,9 @@ void Player::move()
pos_x_ += vel_x_;
// Si el jugador abandona el area de juego por los laterales, restaura su posición
const float min_x = play_area_.x - 5;
const float max_x = play_area_.w + 5 - WIDTH_;
pos_x_ = std::clamp(pos_x_, min_x, max_x);
const float MIN_X = play_area_.x - 5;
const float MAX_X = play_area_.w + 5 - WIDTH_;
pos_x_ = std::clamp(pos_x_, MIN_X, MAX_X);
shiftSprite();
break;
@@ -176,12 +181,12 @@ void Player::move()
case PlayerState::DYING:
{
// Si el cadaver abandona el area de juego por los laterales lo hace rebotar
const int x = player_sprite_->getPosX();
const int min_x = play_area_.x;
const int max_x = play_area_.x + play_area_.w - WIDTH_;
if ((x < min_x) || (x > max_x))
const int X = player_sprite_->getPosX();
const int MIN_X = play_area_.x;
const int MAX_X = play_area_.x + play_area_.w - WIDTH_;
if ((X < MIN_X) || (X > MAX_X))
{
player_sprite_->setPosX(std::clamp(x, min_x, max_x));
player_sprite_->setPosX(std::clamp(X, MIN_X, MAX_X));
player_sprite_->setVelX(-player_sprite_->getVelX());
playRandomBubbleSound();
}
@@ -287,7 +292,6 @@ void Player::move()
{
pos_x_ = param.game.game_area.rect.w - WIDTH_;
vel_x_ *= -1;
// setInputPlaying(InputType::LEFT);
}
}
else
@@ -297,7 +301,6 @@ void Player::move()
{
pos_x_ = param.game.game_area.rect.x;
vel_x_ *= -1;
// setInputPlaying(InputType::RIGHT);
}
}
@@ -356,17 +359,20 @@ void Player::setAnimation()
// Establece la animación a partir de las cadenas
if (firing_state_ == PlayerState::FIRING_NONE)
{ // No esta disparando
{
// No esta disparando
player_sprite_->setCurrentAnimation(a_walking);
player_sprite_->setFlip(flip_walk);
}
else if (isCooling())
{ // Acaba de disparar
{
// Acaba de disparar
player_sprite_->setCurrentAnimation(a_walking + "-" + a_cooling + "-cooldown");
player_sprite_->setFlip(flip_cooling);
}
else
{ // Está disparando
{
// Está disparando
player_sprite_->setCurrentAnimation(a_walking + "-" + a_firing);
// Si dispara de lado, invierte el sprite segun hacia donde dispara
// Si dispara recto, invierte el sprite segun hacia donde camina