create mixer objects

This commit is contained in:
chrys 2016-03-21 00:28:21 +01:00
parent f22cd5a191
commit 024e764511
2 changed files with 6 additions and 5 deletions

View File

@ -16,8 +16,9 @@ def initialize_gui(gameTitle):
# start the display (required by the event loop) # start the display (required by the event loop)
pygame.display.set_mode((320, 200)) pygame.display.set_mode((320, 200))
pygame.display.set_caption(gameTitle) pygame.display.set_caption(gameTitle)
# Load sounds from the sound directory and creates a dict like that {'bottle': 'bottle.ogg'} # Load sounds from the sound directory and creates a list like that {'bottle': 'bottle.ogg'}
soundFiles = {f.split('.')[0]:f for f in listdir(SoundFolder) if isfile(join(SoundFolder, f))} soundFiles = [f for f in listdir(SoundFolder) if isfile(join(SoundFolder, f)) and (f.split('.')[1].lower() == "ogg")]
#lets make a dict with pygame.mixer.Sound() objects {'bottle':<soundobject>}
soundData = {}
for f in soundFiles:
soundData[f.split('.')[0]] = pygame.mixer.Sound(SoundFolder + "/" + f)