pygame documentation | || Home || Help Contents || || pygame || cdrom || constants || display || draw || event || || font || image || joystick || key || mixer || mixer_music || || mouse || movie || sndarray || surfarray || time || transform || || CD || Channel || Clock || Font || Joystick || Movie || || Rect || Sound || Surface || || color || cursors || sprite ||

## pygame.time

Contains routines to help keep track of time. The timer resolution on most systems is around 10ms.
All times are represented in milliseconds, which is simply Seconds*1000. (therefore 2500 milliseconds is 2.5 seconds)
You can also create Clock instances to keep track of framerate.

Clock | - create a new clock
delay | - accurately delay for a number of milliseconds
get_ticks | - milliseconds since initialization
set_timer | - control timer events
wait | - yielding delay for a number of milliseconds

Clock
`pygame.time.Clock() -> Clock`

Clocks are used to track and control the framerate of a game. You create the objects with the time.Clock() function. The clock can be used to limit the framerate of a game, as well as track the time used per frame.

delay
`pygame.time.delay(millseconds) -> time`

Will pause for a given number of milliseconds. This function will use the CPU in order to make the delay more accurate than wait().
This returns the actual number of milliseconds used.

get_ticks
`pygame.time.get_ticks() -> int`

This is the time in milliseconds since the pygame.time was imported. Always returns 0 before pygame.init() is called.

set_timer
`pygame.time.set_timer(eventid, milliseconds) -> int`

Every event id can have a timer attached to it. Calling this will set the timer in milliseconds for that event. setting milliseconds to 0 or less will disable that timer. When a timer for an event is set, that event will be placed on the event queue every given number of milliseconds.

wait
`pygame.time.wait(millseconds) -> time`

Will pause for a given number of milliseconds. This function sleeps the process to better share the CPU with other processes. It is less accurate than the delay() function.
This returns the actual number of milliseconds used.