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 ||

## 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. Use the pygame.time.Clock() function to create new Clock objects.

get_fps | - get the current rate of frames per second
get_rawtime | - get number of nondelayed milliseconds between last two calls to tick()
get_time | - get number of milliseconds between last two calls to tick()
tick | - control timer events

get_fps
`Clock.get_fps() -> float`

This computes the running average of frames per second. This is the number of times the tick() method has been called per second.

get_rawtime
`Clock.get_rawtime() -> int`

This is similar to get_time(). It does not include the number of milliseconds that were delayed to keep the clock tick under a given framerate.

get_time
`Clock.get_time() -> int`

This is the same value returned from the call to Clock.tick(). it is the number of milliseconds that passed between the last two calls to tick().

tick
`Clock.tick([ticks_per_sec_delay]) -> milliseconds`

Updates the number of ticks for this clock. It should usually be called once per frame. If you pass the optional delay argument the function will delay to keep the game running slower than the given ticks per second. The function also returns the number of milliseconds passed since the previous call to tick().