import pygame as pg
pg.init()
clock = pg.time.Clock()
run = True
while run:
clock.tick(144)
tick()
update the clock
tick(framerate=0) -> milliseconds
This method should be called once per frame. It will compute how many milliseconds have passed since the previous call.
If you pass the optional framerate argument the function will delay to keep the game running slower than the given ticks per second. This can be used to help limit the runtime speed of a game. By calling Clock.tick(40) once per frame, the program will never run at more than 40 frames per second.
Note that this function uses SDL_Delay function which is not accurate on every platform, but does not use much CPU. Use tick_busy_loop if you want an accurate timer, and don't mind chewing CPU.