Skip to content

Instantly share code, notes, and snippets.

@stelcheck
Last active May 8, 2018 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stelcheck/5cc24b714a7055c69ddfc09d9760763a to your computer and use it in GitHub Desktop.
Save stelcheck/5cc24b714a7055c69ddfc09d9760763a to your computer and use it in GitHub Desktop.
Sample code, redux
const framesPerSecond = 30;
const frameTimer = 1000 / framesPerSecond;
const now = () => Date.now();
let timer = null;
function render(previousDelta) {
const start = now();
move(previousDelta);
draw();
const end = now();
const newDelta = end - start;
timer = setTimeout(render, newDelta, frameTimer - newDelta);
}
render(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment