Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualSuperVGA

Posted 12 September 2012 - 12:41 PM

Depending on your application and intended host system, it's actually ok to use sleep(). Sometimes it's unwise to do so, for instance if you're exhausting the cpu time of the system while wanting a higher framerate.
On the other hand, if you're certain that you don't need more game loop cycles than 1000/sleep_time_ms, you can go right ahead.
This will save battery and allow the os schedhuler to give other processes more cpu time.
For most fullscreen applications, the performance is so important that the main thread is never put to sleep().

As for the timing bit, keep that entirely seperate of sleep() . Don't rely on sleep() to set behaviour at an intended speed. Create a multiplier to all moving and animating things, which is set to the estimated framerate (avoiding spikes by smoothing and precalculating) relative to a preset, "denominating" framerate.

Mrs. Pac man made for 30fpson my machine yields approx 1730fps, so i would multiply the speed of all graphical change by 30/1730.

If you're making a multiplayer game, keep in sync with the host at specific intervals, yielding the multiplier which can then be interpolated up or down gradually.

I hope I'm making sense. :)

#1SuperVGA

Posted 12 September 2012 - 12:38 PM

Depending on your application and intended host system, it's actually ok to use sleep(). Sometimes it's unwise to do so, for instance if you're exhausting the cpu time of the system while wanting a higher framerate.
On the other hand, if you're certain that you don't need more game loop cycles than 1000/sleep_time_ms, you can go right ahead.

As for the timing bit, keep that entirely seperate of sleep. Don't rely on sleep() to set behaviour at an intended speed. Create a multiplier to all moving and animating things, which is set to the estimated framerate (avoiding spikes by smoothing and precalculating) relative to a preset, "denominating" framerate.

Mrs. Pac man made for 30fpson my machine yields approx 1730fps, so i would multiply the speed of all graphical change by 30/1730.

If you're making a multiplayer game, keep in sync with the host at specific intervals, yielding the multiplier which can then be interpolated up or down gradually.

I hope I'm making sense. :)

PARTNERS