Skip to content

Instantly share code, notes, and snippets.

@quantumpotato
Created December 7, 2015 00:54
Show Gist options
  • 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