| Module | Rubygame::Time |
| In: |
lib/rubygame/clock.rb
ext/rubygame/rubygame_transform.c |
The Time module provides methods for tracking running time and delaying execution of the program for specified time periods. This is used to provide a consistent framerate, prevent the program from gluttonizing all the resources of the computer, etc.
See also the Clock class, which uses these methods to provide a convenient way to monitor and and limit application framerate.
Use the CPU to more accurately wait for the given period. Returns the actual delay time, in milliseconds. This function is more accurate than wait, but is also more CPU-intensive.
The Rubygame timer system will be initialized when you call this function, if it has not been already.
This function takes these arguments:
| time: | the time in milliseconds to delay. |
| gran: | the granularity (in milliseconds) to assume for the system. A smaller value should use less CPU time, but if it‘s lower than the actual system granularity, this function might wait too long. The default, 12 ms, has a fairly low risk of over-waiting for many systems. |
Wait approximately the given time (the accuracy depends upon processor scheduling, but 10ms is common). Returns the actual delay time, in milliseconds. This method is less CPU-intensive than delay, but is slightly less accurate.
The Rubygame timer system will be initialized when you call this function, if it has not been already.
This function takes this argument:
| time: | the time in milliseconds to wait. |