Another update — I changed the timer code.
Earlier on
Windows, the game consumed all available power of one processor core. Currently, the clock class uses the
Sleep procedure to wait between frames, which saves power. And this clock mode is now the default mode on this platform.
However, using the
Sleep procedure makes framerate easier to destabilize and thus reduce the smoothness of the animations. Therefore, the clock has an additional mode that does not use the
Sleep procedure — as before, it eats all the core power. The advantage is that the framerate is very stable.
Both clock modes were tested on three laptops, with
WinXP 32-bit,
Win7 64-bit and with
Win10 64-bit — everywhere worked excellent. So, it was a good improvement.
The clock mode can be defined using the run parameters. A light clock is set up like this:
> platformer.exe clock light
and the precise clock like this:
> platformer.exe clock precise
On
Unixes, the
clock parameter is not used, so even if passed, it is ignored. On these systems, the game always uses high precision measurements and saves the CPU power, thanks to
FPNanoSleep procedure.
The second function that saves the processor's power is a new way of making delays between frames when the game is stopped (using the
F2 key or after deactivating the window). Currently, the
Sleep(100) is used, so the CPU load in such a situation does not exceed
2%. And this behavior applies to all platforms.
Fresh sources in the attachment — fell free to test.
