Is there a simple way to make a game loop in JavaScript? something like...
onTimerTick() {
// update game state
}
Yep. You want setInterval:
function myMainLoop () {
// do stuff...
}
setInterval(myMainLoop, 30);
Would this do?
setInterval(updateGameState, 1000 / 25);
Where 25 is your desired FPS. You could also put there the amount of milliseconds between frames, which at 25 fps would be 40ms (1000 / 25 = 40).