Good day! Judging by the documentation, the line pygame.time.set_timer(pygame.USEREVENT, 1000) sets a timer for 1s, after which the USEREVENT event will be created. I have this line in an infinite loop, updated every ~33ms. Then, as far as I understand, USEREVENT should not be received at all, because every 33ms iteration I update the timer by 1000ms.
import pygame
pygame.init()
sc = pygame.display.set_mode((500, 604))
clock = pygame.time.Clock()
while True:
pygame.time.set_timer(pygame.USEREVENT, 1000)
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
elif event.type == pygame.USEREVENT:
print('event')
clock.tick(30)
But in practice, something else happens: sometimes an event is not thrown for several seconds, sometimes several pieces are thrown: one event every one or two iterations. Maybe I don't understand something about how pygame.time.set_timer() works?
The presented code does not make sense, it only illustrates the problem that I encountered
I write in PyCharm