I am learning HTML 5 game programming. I encounter a code that
var pingpong = {};
pingpong.pressedKeys = [];
$(function(){
pingpong.timer = setInterval(gameloop,30);
function gameloop() {
movePaddles();
} //end of gameloop()
}); //end of $(fn)
Then author says that
We have a timer to execute some game-related code every 30 milliseconds, so this
code is executed 33.3 times per second.
I want to ask that how it is 33.3 times per second? How can we calculate it ?
Thanks
A second is 1000 milliseconds, and
setInterval(gameloop, 30)makes sure the code runs every 30 milliseconds, thus,1000 / 30 = 33.3.