title: How to display text for only a certain amount of time?
body: <p>I'm looking to display a message on the screen when a player wins, and get the text to display for 5 seconds, and then go back to the main menu start screen. Using the time.delay function however, my screen pauses and then displays the text in a flash, but then immediately goes to the startscreen. Is there a more efficient way of getting the text to be displayed for long enough to be read?</p>
  
  <p>Below is the function I use to actually display the message:</p>
  
  <pre><code>def winnerPlayerOne():
      screen.fill(PINK)
      winnerP1Message = winnerFont.render("Congrats Player 1. You Win!", True, WHITE)
      screen.blit(winnerP1Message, ((400 - (winnerP1Message.get_width()/2)),(300 - (winnerP1Message.get_height()/2))))
      pygame.display.update()
      pygame.time.delay(5000)
  
      startscreen()
  </code></pre>
  
  <p>And below this is how I call this function, within the main loop:</p>
  
  <pre><code>        if playeroneScore == 5:
              winnerPlayerOne()
  
          if playertwoScore == 5:
              winnerPlayerTwo()
  </code></pre>
  
  <p>Any help would be greatly appreciated!</p>