1

This is the code for my blinking text, the text is blinking/flashing but the program will crash after a few seconds of blinking.

blink_start = True
blink = True
while blink_start:
    clock.tick(10)

    if blink:
        screen.blit(start, (200, 300))
        blink = False
    else:
        screen.blit(start2, (200, 300))
        blink = True
    pygame.display.flip()
Rabbid76
  • 202,892
  • 27
  • 131
  • 174

1 Answers1

0

You have to handle the events in the application loop. See pygame.event.get() respectively pygame.event.pump():

For each frame of your game, you will need to make some sort of call to the event queue. This ensures your program can internally interact with the rest of the operating system.

blink_start = True
blink = True
while blink_start:
    clock.tick(10)

    pygame.event.pump() # <--- this is missing 

    if blink:
        screen.blit(start, (200, 300))
        blink = False
    else:
        screen.blit(start2, (200, 300))
        blink = True
    pygame.display.flip()
Rabbid76
  • 202,892
  • 27
  • 131
  • 174