October 2018
Intermediate to advanced
500 pages
12h 40m
English
The render and onFrame functions look exactly the same as in the previous examples:
function onFrame() { elapsedTime = (new Date).getTime() - initialTime; if (elapsedTime < animationRate) return; let steps = Math.floor(elapsedTime / animationRate); while (steps > 0) { animate(); steps -= 1; } initialTime = (new Date).getTime();}function render() { initialTime = (new Date).getTime(); setInterval(onFrame, animationRate / 1000);}