I want to count time in pygame, when an event occurs. Ive read something in the documentation but I dont really understand on how to do it.
In the documentation you can get time in miliseconds but it starts counting when the pygame.init() is called. I want to count from 0 when the boolean is true.
import pygame
pygame.init()
loop = True
boolean = False
while loop:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.RETURN:
boolean = True
screen.fill((255, 255, 255))
if boolean:
# start counting seconds
pygame.display.update()
Thanks for your time.
To determine the time that has passed since a certain event, you just measure the time at that event and subtract it from the current time.
Here's a working example: