intro acabada

This commit is contained in:
2026-04-03 20:40:54 +02:00
parent ce2fcefd71
commit 5f7fb8625d
6 changed files with 106 additions and 67 deletions

View File

@@ -13,9 +13,9 @@ CardSprite::CardSprite(std::shared_ptr<Texture> texture)
entry_easing_(easeOutBounce) {}
// Inicia la animación de entrada (solo si está en IDLE)
void CardSprite::enable() {
auto CardSprite::enable() -> bool {
if (state_ != CardState::IDLE) {
return;
return false;
}
state_ = CardState::ENTERING;
@@ -34,6 +34,7 @@ void CardSprite::enable() {
rotate_.center = {pos_.w / 2.0F, pos_.h / 2.0F};
shadow_visible_ = true;
return true;
}
// Inicia la animación de salida (solo si está en LANDED)
@@ -43,7 +44,7 @@ void CardSprite::startExit() {
}
state_ = CardState::EXITING;
shadow_visible_ = false;
shadow_visible_ = true;
// Velocidad y aceleración de salida
vx_ = exit_vx_;
@@ -109,11 +110,21 @@ void CardSprite::updateEntering(float delta_time) {
}
}
// Animación de salida: movimiento + rotación continua
// Animación de salida: movimiento + rotación continua + zoom opcional
void CardSprite::updateExiting(float delta_time) {
move(delta_time);
rotate(delta_time);
// Ganar altura gradualmente (zoom hacia el objetivo)
if (exit_zoom_speed_ > 0.0F && horizontal_zoom_ < exit_target_zoom_) {
float new_zoom = horizontal_zoom_ + exit_zoom_speed_ * delta_time;
if (new_zoom > exit_target_zoom_) {
new_zoom = exit_target_zoom_;
}
horizontal_zoom_ = new_zoom;
vertical_zoom_ = new_zoom;
}
if (isOffScreen()) {
state_ = CardState::FINISHED;
}
@@ -153,9 +164,8 @@ void CardSprite::renderShadow() {
// Offset respecto a la tarjeta: base + extra proporcional a la altura
// La sombra se aleja en diagonal abajo-derecha (opuesta a la luz en 0,0)
static constexpr float HEIGHT_MULTIPLIER = 300.0F;
float offset_x = shadow_offset_x_ + height * HEIGHT_MULTIPLIER;
float offset_y = shadow_offset_y_ + height * HEIGHT_MULTIPLIER;
float offset_x = shadow_offset_x_ + height * SHADOW_HEIGHT_MULTIPLIER;
float offset_y = shadow_offset_y_ + height * SHADOW_HEIGHT_MULTIPLIER;
shadow_texture_->render(
pos_.x + offset_x,
@@ -163,8 +173,8 @@ void CardSprite::renderShadow() {
&sprite_clip_,
shadow_zoom,
shadow_zoom,
0.0,
nullptr,
rotate_.angle,
&rotate_.center,
flip_);
}
@@ -173,9 +183,9 @@ auto CardSprite::isOffScreen() const -> bool {
float effective_width = pos_.w * horizontal_zoom_;
float effective_height = pos_.h * vertical_zoom_;
return (pos_.x + effective_width < -OFF_SCREEN_MARGIN ||
pos_.x > screen_width_ + OFF_SCREEN_MARGIN ||
pos_.y + effective_height < -OFF_SCREEN_MARGIN ||
pos_.y > screen_height_ + OFF_SCREEN_MARGIN);
pos_.x > screen_width_ + OFF_SCREEN_MARGIN ||
pos_.y + effective_height < -OFF_SCREEN_MARGIN ||
pos_.y > screen_height_ + OFF_SCREEN_MARGIN);
}
// --- Consultas de estado ---
@@ -225,6 +235,11 @@ void CardSprite::setExitParams(float vx, float vy, float ax, float ay, double ro
exit_rotate_amount_ = rotate_amount;
}
void CardSprite::setExitLift(float target_zoom, float zoom_speed) {
exit_target_zoom_ = target_zoom;
exit_zoom_speed_ = zoom_speed;
}
void CardSprite::setShadowTexture(std::shared_ptr<Texture> texture) {
shadow_texture_ = std::move(texture);
}