javascriptgame-loop

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
}

Solution

  • setInterval(onTimerTick, 33); // 33 milliseconds = ~ 30 frames per sec
    
    function onTimerTick() {
        // Do stuff.
    }