Skip to content

Instantly share code, notes, and snippets.

@LucasIron
Last active October 1, 2018 16:28
Show Gist options
  • Select an option

  • Save LucasIron/24d7b3e9b1687bfd586cefa650696653 to your computer and use it in GitHub Desktop.

Select an option

Save LucasIron/24d7b3e9b1687bfd586cefa650696653 to your computer and use it in GitHub Desktop.
requestAnimationFrame Game Loop with delta time calculation
export default callback => requestAnimationFrame((function loop(then) {
return now => {
const delta = now - then;
callback(delta);
return requestAnimationFrame(loop(now));
}
})(performance.now()));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment