Noves animacions per a deixar de disparar
This commit is contained in:
@@ -239,9 +239,11 @@ void Player::setAnimation()
|
||||
// Crea cadenas de texto para componer el nombre de la animación
|
||||
const std::string a_walking = status_walking_ == PlayerStatus::WALKING_STOP ? "stand" : "walk";
|
||||
const std::string a_firing = status_firing_ == PlayerStatus::FIRING_UP ? "centershoot" : "sideshoot";
|
||||
const std::string a_cooling = status_firing_ == PlayerStatus::COOLING_UP ? "centershoot" : "sideshoot";
|
||||
|
||||
const SDL_RendererFlip flip_walk = status_walking_ == PlayerStatus::WALKING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;
|
||||
const SDL_RendererFlip flip_fire = status_firing_ == PlayerStatus::FIRING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;
|
||||
const SDL_RendererFlip flip_cooling = status_firing_ == PlayerStatus::COOLING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;
|
||||
|
||||
// Establece la animación a partir de las cadenas
|
||||
if (isPlaying() || isEnteringNameGameCompleted() || isGameCompleted())
|
||||
@@ -251,12 +253,17 @@ void Player::setAnimation()
|
||||
player_sprite_->setCurrentAnimation(a_walking);
|
||||
player_sprite_->setFlip(flip_walk);
|
||||
}
|
||||
else if (isCooling())
|
||||
{ // Acaba de disparar
|
||||
player_sprite_->setCurrentAnimation(a_walking + "-" + a_cooling + "-cooldown");
|
||||
player_sprite_->setFlip(flip_cooling);
|
||||
}
|
||||
else
|
||||
{ // 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
|
||||
a_firing == "centershoot" ? player_sprite_->setFlip(flip_walk) : player_sprite_->setFlip(flip_fire);
|
||||
player_sprite_->setFlip(a_firing == "centershoot" ? flip_walk : flip_fire);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -292,15 +299,36 @@ void Player::updateCooldown()
|
||||
{
|
||||
if (cooldown_ > 0)
|
||||
{
|
||||
cooldown_--;
|
||||
if (power_up_)
|
||||
{
|
||||
cooldown_--;
|
||||
}
|
||||
cooldown_ -= power_up_ ? 2 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
setFiringStatus(PlayerStatus::FIRING_NONE);
|
||||
if (!isCooling())
|
||||
{
|
||||
cooling_status_counter_ = 40;
|
||||
switch (status_firing_)
|
||||
{
|
||||
case PlayerStatus::FIRING_LEFT:
|
||||
status_firing_ = PlayerStatus::COOLING_LEFT;
|
||||
break;
|
||||
case PlayerStatus::FIRING_RIGHT:
|
||||
status_firing_ = PlayerStatus::COOLING_RIGHT;
|
||||
break;
|
||||
case PlayerStatus::FIRING_UP:
|
||||
status_firing_ = PlayerStatus::COOLING_UP;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (cooling_status_counter_ > 0)
|
||||
{
|
||||
--cooling_status_counter_;
|
||||
}
|
||||
else
|
||||
{
|
||||
setFiringStatus(PlayerStatus::FIRING_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,4 +723,6 @@ void Player::shiftSprite()
|
||||
player_sprite_->setPosX(pos_x_);
|
||||
player_sprite_->setPosY(pos_y_);
|
||||
power_sprite_->setPosX(getPosX() - power_up_desp_x_);
|
||||
}
|
||||
}
|
||||
|
||||
bool Player::isCooling() { return status_firing_ == PlayerStatus::COOLING_LEFT || status_firing_ == PlayerStatus::COOLING_UP || status_firing_ == PlayerStatus::COOLING_RIGHT; }
|
||||
Reference in New Issue
Block a user