refactor: Simplify player animation update logic
This commit is contained in:
parent
0c8e13d630
commit
04295f9f9f
@ -89,9 +89,10 @@ class Player extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateAnimation(deltaTime) {
|
updateAnimation(deltaTime) {
|
||||||
|
|
||||||
// Update animation timer consistently
|
// Update animation timer consistently
|
||||||
this.animationTimer += deltaTime;
|
this.animationTimer += deltaTime;
|
||||||
|
/*
|
||||||
// Only change animation frame at fixed intervals to prevent blinking
|
// Only change animation frame at fixed intervals to prevent blinking
|
||||||
if (this.animationTimer >= this.animationSpeed) {
|
if (this.animationTimer >= this.animationSpeed) {
|
||||||
// Only update animation if actually moving horizontally
|
// Only update animation if actually moving horizontally
|
||||||
@ -105,7 +106,7 @@ class Player extends Entity {
|
|||||||
// Reset timer but keep remainder to maintain smooth timing
|
// Reset timer but keep remainder to maintain smooth timing
|
||||||
this.animationTimer %= this.animationSpeed;
|
this.animationTimer %= this.animationSpeed;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// Only update direction when it actually changes to prevent flipping
|
// Only update direction when it actually changes to prevent flipping
|
||||||
if (Math.abs(this.vx) > 0.005) {
|
if (Math.abs(this.vx) > 0.005) {
|
||||||
const newDirection = this.vx > 0 ? 1 : -1;
|
const newDirection = this.vx > 0 ? 1 : -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user