This commit is contained in:
mileswa1q22
2023-12-20 16:18:39 +00:00
committed by GitHub
parent 1de3062695
commit 30d3260fa1
2 changed files with 14 additions and 17 deletions
+13 -16
View File
@@ -16,19 +16,16 @@ alert("fun yesss🎅🏼 you found santa congrats you won")
function yourmom(){
alert("your mom still in testing")
}
var fps = document.getElementById("fps");
var startTime = Date.now();
var frame = 0;
function tick() {
var time = Date.now();
frame++;
if (time - startTime > 1000) {
fps.innerHTML = (frame / ((time - startTime) / 1000)).toFixed(1);
startTime = time;
frame = 0;
}
window.requestAnimationFrame(tick);
}
tick();
const fpsElem = document.querySelector("#fps");
let then = 0;
function render(now) {
now *= 0.001; // convert to seconds
const deltaTime = now - then; // compute time since last frame
then = now; // remember time for next frame
const fps = 1 / deltaTime; // compute frames per second
fpsElem.textContent = fps.toFixed(1); // update fps display
requestAnimationFrame(render);
}
requestAnimationFrame(render);