The function `requestAnimationFrame(update)` on line 191 [1], typically updates at 60 frames per second [2]. When it fires, it re-calls the `update()` function starting on line 184 [3].
As you say though, it's not 100% reliable in terms of speed, but I imagine 90%+ who play the game get a good experience.
True when using a normal monitor, but could be a problem if using a 120Hz monitor or if the previous call didn't finish fast enough. The best is to use the timestamp requestAnimationFrame sends in to the callback to find time-delta since last call
>> The number of callbacks is usually 60 times per second, but will generally match the display refresh rate in most web browsers as per W3C recommendation.
Yeah I think it typically only gets slower, not faster. But it's a good point - if you're going to run your physics loop in the update loop (not ideal) then your movements should be time based.
As you say though, it's not 100% reliable in terms of speed, but I imagine 90%+ who play the game get a good experience.
[1] https://github.com/bradtraversy/vanillawebprojects/blob/mast...
[2] https://developer.mozilla.org/en-US/docs/Web/API/window/requ...
[3] https://github.com/bradtraversy/vanillawebprojects/blob/mast...