3 ms·
I never looked into it before, but their basic game loop is flawed. It would work fine on Windows, but Linux and Mac have high resolution system timers and SDL_
by babuskov 9y ago
I never looked into it before, but their basic game loop is flawed. It would work fine on Windows, but Linux and Mac have high resolution system timers and SDL_Delay(1) which is called underneath would really sleep 1ms (or maybe 2-3ms, but rarely more). This means that the game would run at 1000 fps and consume much more system resources than needed.
A much better approach would be to calculate how much extra time we have and then sleep that long (optionally minus 1ms to allow for that rare case where you get 2ms sleep). This can be #ifdef'd for non-Windows platforms only.
- fsloth 9y ago"This means that the game would run at 1000 fps and consume much more system resources than needed." I don't really see why this would be a problem for a game which, while running, is generally the most important process for the end user anyway. Of course for services and such background tasks this would be intolerable.
- johnday 9y agoYou're right that it is often the most important thing - but not always. For example, people (myself included) often have a YouTube video playing in the background, which also consumes a lot of resources. Having both may start to cause problems. Regardless it is a good thing to avoid over-computing. It helps those with lower powered computers or people on battery-powered machines.
- deleted 9y ago[deleted]
- fileeditview 9y agoYou can always overwrite the love.run() function and realize your own game loop logic. There are also community libs for this already.
- deleted 9y ago[deleted]