Best way for simple game-loop in Javascript?
Is there a simple way to make a game loop in JavaScript? something like... onTimerTick() { // update game state } setInterval(onTimerTick, 33); // 33 milliseconds = ~ 30 frames per sec function onTimerTick() { // Do stuff. } 1-14x0r There are a varied amount of ways to achieve this using JavaScript depending on your application. A setInterval() or even with a while() statement would do the trick. This will not work for a game loop. JavaScript interpreted by the browser, so it is prone to interrupts. Interrupts will make the play back of your game feel jittery. The webkitRequestAnimationFrame