Yay. it works... I gotta remember to pay more attention to scope lol.
This commit is contained in:
parent
f8597666fa
commit
b271242bc9
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
from storm_games import *
|
from storm_games import *
|
||||||
|
|
||||||
initialize_gui("Bottle Blaster")
|
sounds = initialize_gui("Bottle Blaster")
|
||||||
|
|
||||||
# loop forever (until a break occurs)
|
# loop forever (until a break occurs)
|
||||||
while True:
|
while True:
|
||||||
@ -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)
|
sounds['bottle'].play(-1)
|
||||||
if event.type == pygame.KEYUP:
|
if event.type == pygame.KEYUP:
|
||||||
soundData['bottle'].stop()
|
sounds['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
|
||||||
|
@ -22,3 +22,4 @@ def initialize_gui(gameTitle):
|
|||||||
soundData = {}
|
soundData = {}
|
||||||
for f in soundFiles:
|
for f in soundFiles:
|
||||||
soundData[f.split('.')[0]] = pygame.mixer.Sound("sounds/" + f)
|
soundData[f.split('.')[0]] = pygame.mixer.Sound("sounds/" + f)
|
||||||
|
return soundData
|
||||||
|
Loading…
Reference in New Issue
Block a user