Auroriax / PuzzleScriptPlus

Puzzlescript Plus: Open Source HTML5 Puzzle Game Engine (with lots of extra functionality)
https://auroriax.github.io/PuzzleScript/
34 stars 4 forks source link

redo mainloop with requestAnimationFrame #83

Closed pancelor closed 1 year ago

pancelor commented 1 year ago

fixes #81

Auroriax commented 1 year ago

So this got a bit wordy, but the gist is that the merge is accepted as-is!

The original behavior is definitely strange. In your report you mention that Chrome is slower Firefox, whereas for me the opposite seems to be true for me. (But my monitor is apparently set to ~50Hz, whereas I presume most monitors will target ~60Hz by default, which might be related?)

Now some things can feel a bit too fast, perhaps? e.g. the quitting title screen animation now feels very fast. I also think I want to change the timing for most of my games, as I've used Firefox which is notably slower, and I'm not sure if this will affect more devs. I'll likely add a warning in the docs for this. I don't think this is a big problem, the only thing I've noticed is that pressing ESC in a game with a level select will very quickly quit the level select again (which I've fixed already).

I'd argue that the game loop could use more improvements (e.g. the mainloop.js you linked seems interesting), however the game loop is such a complex topic, and at the moment it seems overkill to dive too deeply into it for an engine mostly used for non-realtime games. However, otherwise the fix is simple and effective in cases that do require it.