migrant a SDL3
This commit is contained in:
@@ -350,34 +350,34 @@ void Player::setAnimation()
|
||||
case PlayerState::CREDITS:
|
||||
{
|
||||
// Crea cadenas de texto para componer el nombre de la animación
|
||||
const std::string a_walking = walking_state_ == PlayerState::WALKING_STOP ? "stand" : "walk";
|
||||
const std::string a_firing = firing_state_ == PlayerState::FIRING_UP ? "centershoot" : "sideshoot";
|
||||
const std::string a_cooling = firing_state_ == PlayerState::COOLING_UP ? "centershoot" : "sideshoot";
|
||||
const std::string WALKING_ANIMATION = walking_state_ == PlayerState::WALKING_STOP ? "stand" : "walk";
|
||||
const std::string FIRING_ANIMATION = firing_state_ == PlayerState::FIRING_UP ? "centershoot" : "sideshoot";
|
||||
const std::string COOLING_ANIMATION = firing_state_ == PlayerState::COOLING_UP ? "centershoot" : "sideshoot";
|
||||
|
||||
const SDL_RendererFlip flip_walk = walking_state_ == PlayerState::WALKING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;
|
||||
const SDL_RendererFlip flip_fire = firing_state_ == PlayerState::FIRING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;
|
||||
const SDL_RendererFlip flip_cooling = firing_state_ == PlayerState::COOLING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;
|
||||
const SDL_FlipMode FLIP_WALK = walking_state_ == PlayerState::WALKING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;
|
||||
const SDL_FlipMode FLIP_FIRE = firing_state_ == PlayerState::FIRING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;
|
||||
const SDL_FlipMode FLIP_COOLING = firing_state_ == PlayerState::COOLING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;
|
||||
|
||||
// Establece la animación a partir de las cadenas
|
||||
if (firing_state_ == PlayerState::FIRING_NONE)
|
||||
{
|
||||
// No esta disparando
|
||||
player_sprite_->setCurrentAnimation(a_walking);
|
||||
player_sprite_->setFlip(flip_walk);
|
||||
player_sprite_->setCurrentAnimation(WALKING_ANIMATION);
|
||||
player_sprite_->setFlip(FLIP_WALK);
|
||||
}
|
||||
else if (isCooling())
|
||||
{
|
||||
// Acaba de disparar
|
||||
player_sprite_->setCurrentAnimation(a_walking + "-" + a_cooling + "-cooldown");
|
||||
player_sprite_->setFlip(flip_cooling);
|
||||
player_sprite_->setCurrentAnimation(WALKING_ANIMATION + "-" + COOLING_ANIMATION + "-cooldown");
|
||||
player_sprite_->setFlip(FLIP_COOLING);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Está disparando
|
||||
player_sprite_->setCurrentAnimation(a_walking + "-" + a_firing);
|
||||
player_sprite_->setCurrentAnimation(WALKING_ANIMATION + "-" + FIRING_ANIMATION);
|
||||
// Si dispara de lado, invierte el sprite segun hacia donde dispara
|
||||
// Si dispara recto, invierte el sprite segun hacia donde camina
|
||||
player_sprite_->setFlip(a_firing == "centershoot" ? flip_walk : flip_fire);
|
||||
player_sprite_->setFlip(FIRING_ANIMATION == "centershoot" ? FLIP_WALK : FLIP_FIRE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user