user6698006
user6698006

Reputation:

How Do You Display an Image if a Condition is True?

I'm trying to get an image in pygame to display after a collision is detected. But the problem I'm having is that the image only displays when the IF condition is true. Is there any way that I can get the image to stay if the condition is only true once?

Syntax /

#Game Over
if collision == True:
    SCREEN.blit(start_menu, (0, 0))
    SCREEN.blit(final_score, (800, 5))

NOTE: I already have a while statement and a for loop running under this program

Upvotes: 0

Views: 1862

Answers (1)

Qwerty
Qwerty

Reputation: 1267

Here is a way:

  1. Make a variable:

    GameOver = False
    
  2. Use the if statement you use to detect collision

    if collision == True:
        GameOver = True
    
  3. Display your blit with this variable

    if GameOver == True:
        SCREEN.blit(start_menu, (0, 0))
        SCREEN.blit(final_score, (800, 5))
    

Please tell me if this helped!

Upvotes: 1

Related Questions