time-based: migrada escena Intro (dual-API a MovingSprite/SmartSprite/Writer, constants a 60Hz)

This commit is contained in:
2026-05-18 22:46:41 +02:00
parent f1a6636222
commit 2b57bfa4dd
8 changed files with 218 additions and 90 deletions
+21
View File
@@ -53,6 +53,21 @@ void MovingSprite::move() {
}
}
// Time-based: vx_/vy_ en px/s, ax_/ay_ en px/s^2. Integració d'Euler
// senzilla — suficient per a moviments sense col·lisions sensibles.
void MovingSprite::move(float dt_s) {
if (enabled_) {
x_prev_ = x_;
y_prev_ = y_;
x_ += vx_ * dt_s;
y_ += vy_ * dt_s;
vx_ += ax_ * dt_s;
vy_ += ay_ * dt_s;
}
}
// Muestra el sprite por pantalla
void MovingSprite::render() {
if (enabled_) {
@@ -226,6 +241,12 @@ void MovingSprite::update() {
}
}
// Time-based: nomes move(dt). La rotacio time-based s'integrara quan
// migrem la escena que la requereix (Game/PowerBall).
void MovingSprite::update(float dt_s) {
move(dt_s);
}
// Cambia el sentido de la rotación
void MovingSprite::switchRotate() {
rotate_amount_ *= -1;