ok timer good

This commit is contained in:
awesomeuser 2023-07-08 21:17:02 +00:00
parent 763e8d35f6
commit 712ce5dbdd

View file

@ -79,6 +79,10 @@
</ul> </ul>
<script> <script>
const fps = 30;
var minDt = 1 / fps;
var header = document.getElementById("header"); var header = document.getElementById("header");
var awdog = document.getElementById("awdog"); var awdog = document.getElementById("awdog");
@ -99,9 +103,9 @@
let dt = (timestamp - prevTime) / 1000; let dt = (timestamp - prevTime) / 1000;
prevTime = timestamp; prevTime = timestamp;
if (dt < 0.025) { // fps limiter (40fps) if (dt < minDt) { // fps limiter
await new Promise(r => setTimeout(r, 0.025 - dt)); await new Promise(r => setTimeout(r, minDt - dt));
dt = 0.025; dt = minDt;
} }
// petting shake // petting shake