Learn Before
Pygame
Time in Pygame
Time is represented in milliseconds. The time module is used for retrieving the time and creating clocks. To get the time that has passed since pygame.init() was called, use the following command:
pygame.time.get_ticks()
Both the wait and delay methods will pause the program for a period of time, with wait sleeping the program and using less processor time, but being less accurate as a result. Delay is more accurate but uses the processor to pause the program. You just pass in the amount of time (in ms) you want to pause the program.
pygame.time.wait(milliseconds) pygame.time.delay(milliseconds)
You can also set an event to appear every certain number of ms on the event queue using the set_timer method. Once is an optional parameter that, when set to True, will only call the event once.
pygame.time.set_timer(eventid, time, once)
Clocks can also be created to help track time, and have a number of methods that can be used with them.
0
1
Tags
Python Programming Language
Data Science
Related
Pygame Documentation
Time in Pygame
Surfaces in Pygame
Drawing in Pygame
Images in Pygame
Events in Pygame
Fonts in Pygame
Sounds in Pygame
Learn After
Using Clocks in Pygame