From: TJ Date: Sat, 9 Nov 2013 21:34:26 +0000 (+0000) Subject: Music soundtrack fades out at end of game X-Git-Url: https://iam.tj/gitweb/gitweb.cgi?p=base2-runner.git;a=commitdiff_plain;h=bf0e15cbfdc0d3a79401be6eb4117990cb6360e0 Music soundtrack fades out at end of game --- diff --git a/pygame-scroller.py b/pygame-scroller.py index 3a363b4..30c1ae4 100755 --- a/pygame-scroller.py +++ b/pygame-scroller.py @@ -42,6 +42,11 @@ class Channel: self.channel.queue(sound) def get_queue(self): return self.channel.get_queue() if self.channel != None else None + def fadeout(self, time): + if self.channel == None: + pygame.mixer.music.fadeout(time) + else: + self.channel.fadeout(time) def play(self, sound, loops=0, maxtime=0, fade_ms=0): if self.channel != None: # allow 'sound' to be a path string or an object @@ -184,6 +189,7 @@ while (myGame.play): # volume up myGame.soundtrack.up() +myGame.soundtrack.fadeout(10000) time.sleep(10) pygame.display.quit() exit(0)