polimorfise d'enemics

moving platforms
This commit is contained in:
2026-04-08 14:09:28 +02:00
parent 5e02854e7a
commit 73a520bf3c
20 changed files with 632 additions and 106 deletions

View File

@@ -398,6 +398,9 @@ void Player::checkFalling() {
return;
}
// ON_GROUND: si está sobre una plataforma móvil, no comprobar tiles
if (on_platform_) { return; }
// ON_GROUND: comprobar si sigue habiendo suelo
float foot_y = (y_ + oy) + HEIGHT;
if (!tc.hasGroundBelow(x_ + ox, foot_y, WIDTH)) {
@@ -537,6 +540,18 @@ void Player::syncSpriteAndCollider() {
collider_box_ = getRect();
}
// Aplica el desplazamiento de una plataforma móvil al jugador
void Player::applyPlatformDisplacement(float dx, float surface_y) {
y_ = surface_y - HEIGHT; // Snap vertical al top de la plataforma
x_ += dx; // Desplazamiento horizontal
vy_ = 0.0F;
on_platform_ = true;
if (state_ != State::ON_GROUND) {
transitionToState(State::ON_GROUND);
}
syncSpriteAndCollider();
}
void Player::placeSprite() {
sprite_->setPos(x_, y_);
}