Skip to content

Instantly share code, notes, and snippets.

@stelcheck

stelcheck/render.js

Last active May 8, 2018
Embed
What would you like to do?
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