refactor: Simplify player animation update logic

This commit is contained in:
Kacper Kostka 2025-04-05 18:33:17 +02:00 committed by Kacper Kostka (aider)
parent 0c8e13d630
commit 04295f9f9f

View File

@ -89,9 +89,10 @@ class Player extends Entity {
}
updateAnimation(deltaTime) {
// Update animation timer consistently
this.animationTimer += deltaTime;
/*
// Only change animation frame at fixed intervals to prevent blinking
if (this.animationTimer >= this.animationSpeed) {
// Only update animation if actually moving horizontally
@ -105,7 +106,7 @@ class Player extends Entity {
// Reset timer but keep remainder to maintain smooth timing
this.animationTimer %= this.animationSpeed;
}
*/
// Only update direction when it actually changes to prevent flipping
if (Math.abs(this.vx) > 0.005) {
const newDirection = this.vx > 0 ? 1 : -1;