add fps limit

This commit is contained in:
awesomeuser 2023-07-08 21:12:26 +00:00
parent ce8abd17e7
commit ee4348edae

View file

@ -99,6 +99,11 @@
let dt = (timestamp - prevTime) / 1000;
prevTime = timestamp;
if (dt < 50) { // fps limiter (20fps)
await new Promise(r => setTimeout(r, 50 - dt));
dt = 50;
}
// petting shake
let a = Math.random() * Math.PI * 2;
awdog.style.transform = "translate(" + (Math.cos(a) * intensity) + "px, " + (Math.sin(a) * intensity) + "px)";