From 3c70fb3b9e4e4b05ca6a44c0950b6ac5619a95c8 Mon Sep 17 00:00:00 2001 From: mileswa1q22 <115095719+mileswolfallen2@users.noreply.github.com> Date: Fri, 5 Jan 2024 18:35:19 +0000 Subject: [PATCH] idk --- fun.js | 28 +++++++++++++++------------- index.html | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/fun.js b/fun.js index a3910099..8d3a974a 100644 --- a/fun.js +++ b/fun.js @@ -16,16 +16,18 @@ alert("fun yesss🎅🏼 you found santa congrats you won") function yourmom(){ alert("your mom still in testing") } - 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); + 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(); \ No newline at end of file diff --git a/index.html b/index.html index 6e1e7afd..b764a107 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ -
fps:
+ -- FPS Beta Games