update calculating fps

This commit is contained in:
Alexander Popov 2023-12-01 16:14:25 +03:00
parent 7a91471a38
commit ea321fc403
Signed by: iiiypuk
GPG Key ID: E47FE0AB36CD5ED6
1 changed files with 4 additions and 3 deletions

View File

@ -52,9 +52,10 @@ export class App {
run = () => {
// Calculating FPS
let newTime = Date.now();
Settings.delta = (newTime - Settings.prevTime) / 1000;
Settings.prevTime = newTime;
let fpsNewTime = Date.now();
Settings.fpsDelta = (fpsNewTime - Settings.fpsPrevTime) / 1000;
Settings.fpsPrevTime = fpsNewTime;
Settings.fps = Math.round(1 / Settings.fpsDelta);
// clear canvas
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);