Yay. it works... I gotta remember to pay more attention to scope lol.

This commit is contained in:
Storm dragon 2016-03-21 06:42:53 -04:00
parent f8597666fa
commit b271242bc9
2 changed files with 4 additions and 3 deletions

View File

@ -4,7 +4,7 @@
from storm_games import *
initialize_gui("Bottle Blaster")
sounds = initialize_gui("Bottle Blaster")
# loop forever (until a break occurs)
while True:
@ -12,9 +12,9 @@ while True:
event = pygame.event.wait()
# if the event is about a keyboard button that have been pressed...
if event.type == pygame.KEYDOWN:
soundData['bottle'].play(-1)
sounds['bottle'].play(-1)
if event.type == pygame.KEYUP:
soundData['bottle'].stop()
sounds['bottle'].stop()
# and if the button is the "q" letter or the "escape" key...
if event.key == pygame.K_ESCAPE:
# ... then exit from the while loop

View File

@ -22,3 +22,4 @@ def initialize_gui(gameTitle):
soundData = {}
for f in soundFiles:
soundData[f.split('.')[0]] = pygame.mixer.Sound("sounds/" + f)
return soundData