Skip to content

Commit

Permalink
fix: don't waste time calculating ~ 0 velocity
Browse files Browse the repository at this point in the history
  • Loading branch information
Stan-Stani committed Nov 20, 2023
1 parent c56c8cf commit 4bf7980
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ class GameScene extends Scene {
this.#playerOne?.body?.acceleration
)

// Don't waste time calculating super small velocity endlessly for drag
if ((Math.abs(this.#playerOne?.body?.velocity.x ?? 0) < .1) && (this.#playerOne?.body?.acceleration.x === 0)) {
this.#playerOne.body.velocity.x = 0
}

if (!this.#textbox) {
return
}
Expand Down

0 comments on commit 4bf7980

Please sign in to comment.