Last active
October 1, 2018 16:28
-
-
Save LucasIron/24d7b3e9b1687bfd586cefa650696653 to your computer and use it in GitHub Desktop.
requestAnimationFrame Game Loop with delta time calculation
This file contains hidden or 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
| 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