Expand description
Timing and measurement functions.
ggez does not try to do any framerate limitation by default. If
you want to run at anything other than full-bore max speed all the
time, call thread::yield_now()
(or timer::yield_now()
which does the same
thing) to yield to the OS so it has a chance to breathe before continuing
with your game. This should prevent it from using 100% CPU as much unless it
really needs to. Enabling vsync by setting
conf.window_setup.vsync
in your Conf
object is generally the best
way to cap your displayed framerate.
For a more detailed tutorial in how to handle frame timings in games, see http://gafferongames.com/game-physics/fix-your-timestep/
Structs§
- Time
Context - A structure that contains our time-tracking state.
Functions§
- average_
delta Deprecated - Gets the average time of a frame, averaged over the last 200 frames.
- check_
update_ time Deprecated - Check whether or not the desired amount of time has elapsed since the last frame.
- delta
Deprecated - Get the time between the start of the last frame and the current one; in other words, the length of the last frame.
- fps
Deprecated - Gets the FPS of the game, averaged over the last 200 frames.
- remaining_
update_ time Deprecated - Returns the fractional amount of a frame not consumed
by
check_update_time()
. For example, if the desired update frame time is 40 ms (25 fps), and 45 ms have passed since the last frame,check_update_time()
will returntrue
andremaining_update_time()
will return 5 ms – the amount of time “overflowing” from one frame to the next. - sleep
- Pauses the current thread for the target duration.
Just calls
std::thread::sleep()
so it’s as accurate as that is (which is usually not very). - ticks
Deprecated - Gets the number of times the game has gone through its event loop.
- time_
since_ start Deprecated - Returns the time since the game was initialized, as reported by the system clock.
- yield_
now - Yields the current timeslice to the OS.