From 04295f9f9f4e42f306b66d2fea368f89c9852b90 Mon Sep 17 00:00:00 2001 From: Kacper Kostka Date: Sat, 5 Apr 2025 18:33:17 +0200 Subject: [PATCH] refactor: Simplify player animation update logic --- js/entities/player.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/entities/player.js b/js/entities/player.js index 4b8351e..4d06fe8 100644 --- a/js/entities/player.js +++ b/js/entities/player.js @@ -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;