Added a cut_scene function. used a space between spoken strings with the space key in display_text.
This commit is contained in:
parent
8d90030011
commit
6c367f78d1
@ -64,6 +64,8 @@ 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)
|
||||||
|
# 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'}
|
# 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"])]
|
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>}
|
||||||
@ -74,6 +76,18 @@ def initialize_gui(gameTitle):
|
|||||||
time.sleep(soundData['game-intro'].get_length())
|
time.sleep(soundData['game-intro'].get_length())
|
||||||
return soundData
|
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):
|
def play_random(sounds, soundName, pause = False):
|
||||||
key = []
|
key = []
|
||||||
for i in sounds.keys():
|
for i in sounds.keys():
|
||||||
|
Loading…
Reference in New Issue
Block a user