magic numbers: moving_sprite.cpp i game_logo.cpp
This commit is contained in:
@@ -55,14 +55,13 @@ void MovingSprite::stop() {
|
||||
|
||||
// Mueve el sprite (time-based)
|
||||
void MovingSprite::move(float deltaTime) {
|
||||
// Convertir deltaTime (milisegundos) a factor de frame (asumiendo 60fps)
|
||||
float frameFactor = deltaTime / (1000.0f / 60.0f);
|
||||
|
||||
x_ += vx_ * frameFactor;
|
||||
y_ += vy_ * frameFactor;
|
||||
// DeltaTime puro: velocidad (pixels/ms) * tiempo (ms)
|
||||
x_ += vx_ * deltaTime;
|
||||
y_ += vy_ * deltaTime;
|
||||
|
||||
vx_ += ax_ * frameFactor;
|
||||
vy_ += ay_ * frameFactor;
|
||||
// Aceleración (pixels/ms²) * tiempo (ms)
|
||||
vx_ += ax_ * deltaTime;
|
||||
vy_ += ay_ * deltaTime;
|
||||
|
||||
pos_.x = static_cast<int>(x_);
|
||||
pos_.y = static_cast<int>(y_);
|
||||
@@ -82,7 +81,7 @@ void MovingSprite::render() {
|
||||
// Establece la rotacion (time-based)
|
||||
void MovingSprite::rotate(float deltaTime) {
|
||||
if (rotate_.enabled) {
|
||||
// Convertir speed (frames) a tiempo: speed frames = speed * (1000ms/60fps) milisegundos
|
||||
// DeltaTime puro: velocidad de rotación debe estar en unidades/ms
|
||||
float rotationFrameTime = static_cast<float>(rotate_.speed) * (1000.0f / 60.0f);
|
||||
rotate_.angle += rotate_.amount * (deltaTime / rotationFrameTime);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user