Skip to content

Instantly share code, notes, and snippets.

@quantumpotato
Created December 7, 2015 00:54
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 quantumpotato/19788003148b47ea423d to your computer and use it in GitHub Desktop.
Save quantumpotato/19788003148b47ea423d to your computer and use it in GitHub Desktop.
loop() {
this.now = Date.now();
var delta = this.now - this.last;
this.last = this.now;
this.dt = this.dt + delta;
if (this.dt < this.rate) {
window.requestAnimationFrame(this.loop.bind(this));
return;
} else {
this.game.loop();
this.draw();
this.dt = this.dt - this.rate;
}
this.game.loopKeyboardInput(this.key_pressed_map);
window.requestAnimationFrame(this.loop.bind(this));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment