Answer the question
In order to leave comments, you need to log in
How to deal with time.clock in pygame?
import pygame as pg
pg.init()
clock = pg.time.Clock()
run = True
while run:
clock.tick(144)
Answer the question
In order to leave comments, you need to log in
https://www.pygame.org/docs/ref/time.html#pygame.t...
tick()
update the clock
tick(framerate=0) ->
milliseconds 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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question