Last active
May 8, 2018 01:38
-
-
Save stelcheck/5cc24b714a7055c69ddfc09d9760763a to your computer and use it in GitHub Desktop.
Sample code, redux
This file contains 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
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