From c1f1c85d4529c71bdf7b540e64e436ec5e9362a7 Mon Sep 17 00:00:00 2001 From: Steve Clement Date: Sat, 30 Aug 2014 21:41:53 +0200 Subject: [PATCH] - Added initial sound class --- avocado.py | 20 ++++++++++++++++++++ game.py | 2 ++ 2 files changed, 22 insertions(+) diff --git a/avocado.py b/avocado.py index 21ef7f3..9068128 100644 --- a/avocado.py +++ b/avocado.py @@ -80,4 +80,24 @@ class Avocado: print('platch') return True + def mute(self,mute=False): + if mute: + pygame.mixer.music.set_volume(0.0) + else: + pygame.mixer.music.set_volume(0.5) + def playLevel(self,lvl=1): + if lvl == 1: + pygame.mixer.music.load("""audio/level1.wav""") + elif lvl == 2: + pygame.mixer.music.load("""audio/level2.wav""") + elif lvl == 3: + pygame.mixer.music.load("""audio/level3.wav""") + pygame.mixer.music.play() + + def fade(self): + pygame.mixer.music.fadeout(3000) + + def loadClick(self): + self.click = pygame.mixer.Sound("audio/click.wav") + return self.click diff --git a/game.py b/game.py index c4cd111..5470c36 100755 --- a/game.py +++ b/game.py @@ -21,6 +21,8 @@ def initialize_screen(): def main(): pygame.init() + pygame.mixer.init() + pygame.mixer.music.set_volume(0.5) pygame.display.set_caption('Pin Avo, the Cado!') clock = pygame.time.Clock()