Python Forum
[PyGame] Pygame, how to run an if statement only once, help!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Pygame, how to run an if statement only once, help!
#4
said_yeah = False  #<------- put before game loop starts.

if score_value == 10 and said_yeah == False:
   yeah = pygame.mixer.Sound("PointsSound.wav")
   yeah.set_volume(0.1)
   yeah.play()
   said_yeah = True
Ok, sorry. The said_yeah = False needs to be before the game loop starts or it will keep resetting to False on each frame. Should have stated that.
Reply


Messages In This Thread
RE: Pygame, how to run an if statement only once, help! - by michael1789 - Jan-28-2020, 09:33 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020