migrades portes i plataformes a solidActor

This commit is contained in:
2026-04-11 12:54:54 +02:00
parent 49f6ed41e6
commit 5b2f986d32
22 changed files with 686 additions and 286 deletions

View File

@@ -28,13 +28,19 @@ MovingPlatform::MovingPlatform(const Data& data)
speed_(data.speed),
loop_mode_(data.loop),
easing_(resolveEasing(data.easing)) {
// Flags del SolidActor: jump-through desde abajo, carry al Player encima.
// NOTA: sin BLOCKS_PLAYER, las plataformas móviles no bloquean lateralmente
// ni por arriba. ONEWAY_TOP hace que los sweeps verticales solo las vean
// al caer desde arriba.
flags_ = CARRY_ON_TOP | ONEWAY_TOP;
// Colocar el sprite en el primer waypoint
if (!path_.empty()) {
sprite_->setPosX(path_[0].x);
sprite_->setPosY(path_[0].y);
}
collider_ = getRect();
aabb_ = getRect();
// Frame inicial
sprite_->setCurrentAnimationFrame((data.frame == -1) ? (rand() % sprite_->getCurrentAnimationSize()) : data.frame);
@@ -115,8 +121,8 @@ void MovingPlatform::update(float delta_time) {
sprite_->animate(delta_time);
if (path_.size() < 2) {
last_dx_ = 0.0F;
last_dy_ = 0.0F;
last_delta_.x = 0.0F;
last_delta_.y = 0.0F;
return;
}
@@ -130,8 +136,8 @@ void MovingPlatform::update(float delta_time) {
waiting_ = false;
advanceSegment();
} else {
last_dx_ = 0.0F;
last_dy_ = 0.0F;
last_delta_.x = 0.0F;
last_delta_.y = 0.0F;
return;
}
}
@@ -174,9 +180,9 @@ void MovingPlatform::update(float delta_time) {
sprite_->setPosY(new_y);
}
last_dx_ = sprite_->getPosX() - old_x;
last_dy_ = sprite_->getPosY() - old_y;
collider_ = getRect();
last_delta_.x = sprite_->getPosX() - old_x;
last_delta_.y = sprite_->getPosY() - old_y;
aabb_ = getRect();
}
// Pinta la plataforma en pantalla
@@ -208,7 +214,7 @@ void MovingPlatform::resetToInitialPosition(const Data& data) {
sprite_->setPosY(path_[0].y);
}
collider_ = getRect();
aabb_ = getRect();
recalcSegmentLength();
}
#endif
@@ -217,8 +223,3 @@ void MovingPlatform::resetToInitialPosition(const Data& data) {
auto MovingPlatform::getRect() -> SDL_FRect {
return sprite_->getRect();
}
// Obtiene el rectangulo de colisión
auto MovingPlatform::getCollider() -> SDL_FRect& {
return collider_;
}