Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
Merge branch feature/tps-tolerance into main (#62)
Browse files Browse the repository at this point in the history
Implement maximum tickDelta tolerance

Implement maximum tickDelta tolerance, which is hardcoded to 50 for now.
  • Loading branch information
Kitt3120 committed Jun 13, 2023
1 parent a134ec4 commit 8b2b141
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ts/engine/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Game {
private _lastRender: number;

private _tpsGoal: number;
private _tickDeltaTolerance: number;

private _currentTps: number;
private _currentFps: number;
Expand Down Expand Up @@ -49,6 +50,7 @@ class Game {
this._lastRender = Date.now();

this._tpsGoal = 100;
this._tickDeltaTolerance = 50;

this._currentTps = 0;
this._currentFps = 0;
Expand Down Expand Up @@ -94,6 +96,10 @@ class Game {
this._lastTick = now;
this._currentTps = Math.round(1 / (tickDelta / 1000));

if (tickDelta > this._tickDeltaTolerance) {
tickDelta = this._tickDeltaTolerance;
}

this._levelManager.update(tickDelta);
this._entityManager.update(tickDelta);

Expand Down

0 comments on commit 8b2b141

Please sign in to comment.