Jan-28-2020, 04:32 PM
Hey guys.
I have been struggling with this problem for some time now, so i have to ask for help.
I got this game i am developing. You play as a spaceship, where your mission is to kill aliens, you get 1 point/score at each alien kill. I want to make a sound when you got a score of 10 only once. I got the score function working good and it is counting + 1 every time you kill an alien, but when the sound starts at 10 points it is playing that sound continually if i still got the score of 10. When i get 11 points it stops. I have tried with the pygame.mixer.stop after the yeah.play(), but then it isn't playing at all. Any suggestions?
My code look like this:
if score_value == 10:
yeah = pygame.mixer.Sound("PointsSound.wav")
yeah.set_volume(0.1)
yeah.play()
I have been struggling with this problem for some time now, so i have to ask for help.
I got this game i am developing. You play as a spaceship, where your mission is to kill aliens, you get 1 point/score at each alien kill. I want to make a sound when you got a score of 10 only once. I got the score function working good and it is counting + 1 every time you kill an alien, but when the sound starts at 10 points it is playing that sound continually if i still got the score of 10. When i get 11 points it stops. I have tried with the pygame.mixer.stop after the yeah.play(), but then it isn't playing at all. Any suggestions?
My code look like this:
if score_value == 10:
yeah = pygame.mixer.Sound("PointsSound.wav")
yeah.set_volume(0.1)
yeah.play()