Skip to content

Instantly share code, notes, and snippets.

@Pinjontall94
Created August 6, 2025 18:19
Show Gist options
  • Select an option

  • Save Pinjontall94/00d9646e09ab88e1dbea4a1f015eb06b to your computer and use it in GitHub Desktop.

Select an option

Save Pinjontall94/00d9646e09ab88e1dbea4a1f015eb06b to your computer and use it in GitHub Desktop.
gameloop.js
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