Latest code. Still not working.

This commit is contained in:
Storm dragon 2016-03-21 06:34:25 -04:00
parent acf8d58bfa
commit f8597666fa
2 changed files with 4 additions and 4 deletions

View File

@ -12,9 +12,9 @@ while True:
event = pygame.event.wait() event = pygame.event.wait()
# if the event is about a keyboard button that have been pressed... # if the event is about a keyboard button that have been pressed...
if event.type == pygame.KEYDOWN: if event.type == pygame.KEYDOWN:
soundData["bottle"].play(-1) soundData['bottle'].play(-1)
if event.type == pygame.KEYUP: if event.type == pygame.KEYUP:
soundData["bottle"].stop() soundData['bottle'].stop()
# and if the button is the "q" letter or the "escape" key... # and if the button is the "q" letter or the "escape" key...
if event.key == pygame.K_ESCAPE: if event.key == pygame.K_ESCAPE:
# ... then exit from the while loop # ... then exit from the while loop

View File

@ -17,8 +17,8 @@ def initialize_gui(gameTitle):
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 list like that {'bottle': 'bottle.ogg'} # Load sounds from the sound directory and creates a list like that {'bottle': 'bottle.ogg'}
soundFiles = [f for f in listdir(SoundFolder) if isfile(join(SoundFolder, f)) and (f.split('.')[1].lower() in ["ogg","wav"])] soundFiles = [f for f in listdir("sounds/") if isfile(join("sounds/", f)) and (f.split('.')[1].lower() in ["ogg","wav"])]
#lets make a dict with pygame.mixer.Sound() objects {'bottle':<soundobject>} #lets make a dict with pygame.mixer.Sound() objects {'bottle':<soundobject>}
soundData = {} soundData = {}
for f in soundFiles: for f in soundFiles:
soundData[f.split('.')[0]] = pygame.mixer.Sound(SoundFolder + "/" + f) soundData[f.split('.')[0]] = pygame.mixer.Sound("sounds/" + f)