How do I continuously trigger an action at certain time intervals? Enemy shoots constant beam instead of bullets in pygame [duplicate]

I recommend to use a timer event. Use pygame.time.set_timer() to repeatedly create an USEREVENT. e.g.: milliseconds_delay = 500 # 0.5 seconds bullet_event = pygame.USEREVENT + 1 pygame.time.set_timer(bullet_event, milliseconds_delay) Note, in pygame customer events can be defined. Each event needs a unique id. The ids for the user events have to start at pygame.USEREVENT. In this … Read more