How to make it so that when you click the mouse, the screen itself starts to change endlessly?

Display code and images:

def run_game():
    game = True
    while game:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()
        display1()
        scream.play()
        pygame.display.flip()

def display1():
    while True:
        display.blit(disp, (0, 0))
        for e in pygame.event.get():
            while e.type == pygame.MOUSEBUTTONUP:

                display.blit(smile, (0, 0))

                display.blit(smile2, (0, 0))

                display.blit(smile, (0, 0))
                display.blit(smile2, (0, 0))
                pygame.display.update()

When you click the button on the mouse, the picture does not change and then the program crashes without errors

Author: allahgator3000, 2020-11-13

1 answers

You draw smile and smile2 twice and only then updates the screen, you need to add pygame.display.update after each drawing or add a loop for

for smile_ in (smile, smile2):
    display.blit(smile_, (0, 0))
    pygame.display.update()
 1
Author: Danis, 2020-11-13 18:04:43