Added a cut_scene function. used a space between spoken strings with the space key in display_text.

This commit is contained in:
Storm Dragon 2019-12-05 10:30:44 -05:00
parent 8d90030011
commit 6c367f78d1

View File

@ -64,6 +64,8 @@ def initialize_gui(gameTitle):
# start the display (required by the event loop)
pygame.display.set_mode((320, 200))
pygame.display.set_caption(gameTitle)
# Reserve the cut scene channel
pygame.mixer.set_reserved(0)
# Load sounds from the sound directory and creates a list like that {'bottle': 'bottle.ogg'}
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>}
@ -74,6 +76,18 @@ def initialize_gui(gameTitle):
time.sleep(soundData['game-intro'].get_length())
return soundData
def cut_scene(sounds, soundName):
pygame.event.clear()
pygame.mixer.stop()
c = pygame.mixer.Channel(0)
c.play(sounds[soundName])
while pygame.mixer.get_busy():
pygame.event.poll()
if event.type == pygame.KEYDOWN:
pygame.mixer.stop()
pygame.event.pump()
return
def play_random(sounds, soundName, pause = False):
key = []
for i in sounds.keys():