2 ms·
Just wondering, what is the best way to set up the game loop - simply setTimeout? I have considered if it would be worthwhile to try putting the logic into a w
by Tichy 16y ago
Just wondering, what is the best way to set up the game loop - simply setTimeout?
I have considered if it would be worthwhile to try putting the logic into a web worker and trigger update events to the display. Then again, sending an event from the worker to the UI thread will probably be scheduled the same way as a setTimeout event.
It's just that setTimeout seems rather slow. I have created a game with AI in Javascript, which runs fine with web workers. I tried to make it work without workers by frequently interrupting the AI thread with setTimeout events, and it was a lot slower.