0

I'd really like to know the simplest way to implement music while people play the game I created, and for sounds to play during certain events. (such as dying)

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by pyTony
0

I'm having trouble getting the music to stop and the application to close.

Near the head of my program, I have

pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)
pygame.mixer.music.load("theme.mp3")
pygame.mixer.music.play(loops=0, start=0.0)

I inserted

root.protocol("WM_DELETE_WINDOW", endOfGame)

right before my root.mainloop, and end of game is:

def endOfGame():
    pygame.mixer.stop()
    root.destroy()

No matter what I do, it either doesn't stop until 20 seconds after the program is killed, or doesn't close when I hit the X.

Edited by kalookakoo: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.