0

I have a game where after the character completes a level (by destroying all the monsters on the screen), a message should pop up saying "Round Clear!" and then it should move on to the next level. This is my code so far:

if len(monsters) == 0: 
    smallFont = pygame.font.Font(None, 40)
    clearText = smallFont.render('Round Clear!', True, BLACK)
    screen.blit(clearText, (SCREEN_WIDTH*.5, SCREEN_HEIGHT*.5))

    boardIndex += 1
    board = boards[boardIndex]

However, if I do this, the message pops up for less than a second and immediately moves on to the next board. I want some sort of delay to happen where the blank line is in my code so that the message appears for like 3 seconds and then the new board shows. If I use pygame.time.delay(), it messes up the animation that kills the last monster since everything happens so fast.

Does anyone have any tips?

sy89
  • 195
  • 2
  • 14
  • 1
    maybe `import time` and then do `time.sleep(3)`, where the 3 signifies a 3 seconds delay? –  Dec 04 '17 at 16:21
  • 1
    That probably isn't ideal because it will have the same issues as the delay() call and will also probably cause the window to stop responding – Chachmu Dec 04 '17 at 16:35
  • 2
    you can't use `delay()` or `time.sleep` - you have to use `pygame.time.get_ticks()` to control time and execute new function after 3 seconds. Or you can use own event and catch them in `for event` loop to execute function after 3 seconds. Both method need variables like `display_message = True` and in mainloop `if display_message: blit(...)`. Briefly, it will need many changes. – furas Dec 04 '17 at 19:19
  • You have to implement a timer as explained in [these answers](https://stackoverflow.com/q/30720665/6220679). – skrx Dec 04 '17 at 19:45

0 Answers0