Created
August 6, 2025 18:19
-
-
Save Pinjontall94/00d9646e09ab88e1dbea4a1f015eb06b to your computer and use it in GitHub Desktop.
gameloop.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let fps = 0; | |
| let current = performance.now(); | |
| let last = performance.now(); | |
| let elapsed = 0; | |
| function tick() { | |
| window.requestAnimationFrame(() => { | |
| current = performance.now() | |
| elapsed = current - last; | |
| last = current; | |
| fps = 1000 / elapsed; | |
| // input() | |
| // update(elapsed) | |
| // draw() | |
| console.log(`fps: ${fps}`); | |
| tick(); | |
| }); | |
| } | |
| tick(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment