add fps limit
This commit is contained in:
parent
ce8abd17e7
commit
ee4348edae
1 changed files with 5 additions and 0 deletions
|
@ -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)";
|
||||
|
|
Reference in a new issue