| Class | Rubygame::Time::Clock |
| In: |
lib/rubygame/clock.rb
|
| Parent: | Object |
| desired_fps | [RW] | Access the desired number of frames per second. If this is set, tick will add a small delay to each frame to slow down execution if it is running faster than this value. If nil or false, no slowdown will be made to execution. |
Return the desired time (milliseconds) per frames. This is the same as 1000.0/@desired_fps.
Set the desired time (milliseconds) per frames. If this is set, tick will add a small delay to each frame to slow down execution if the natural delay between frames is too small. If nil or false, no slowdown will be made to execution.
This is an alternative to setting @desired_fps directly. You can get exactly the same effect by setting @desired_fps to 1000.0/dmspf.
Call this function once per frame to use framerate tracking. Returns the number of milliseconds since the last time you called the function.
If @desired_fps is set, this function will delay execution for a certain amount of time so that (if you call this function once per frame) the program will run at that framerate.
The accuracy of this method is less than perfect (for me, it runs about 5-15 fps too quickly if the desired fps is less than 100 or so), but it‘s still useful.
(Please note that no effort is made to correct a framerate which is slower than the desired framerate, i.e. it can‘t make your code run any faster, only slow it down if it is running too quickly.)