2
if pygame.sprite.collide_rect(ship,missile) == True:
    ship.image = pygame.image.load("lose.jpg")
    ship.image = ship.image.convert()
    ship.rect = ship.image.get_rect()
    break

How do I make it so there is a few second wait while it shows 'lose.jpg' and then breaks and exits the program?

hichris123
  • 10,145
  • 15
  • 56
  • 70

1 Answers1

2

You can try this:

def pause(time_to_wait):
    clock = pygame.time.Clock()
    total = 0
    while True:
    total += clock.tick()
    if(total > time_to_wait):
        return
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
Bartlomiej Lewandowski
  • 10,771
  • 14
  • 44
  • 75