diff options
Diffstat (limited to 'src/audio.py')
-rw-r--r-- | src/audio.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/audio.py b/src/audio.py index 17ae5ef..baba6da 100644 --- a/src/audio.py +++ b/src/audio.py @@ -5,6 +5,8 @@ pygame.mixer.pre_init(48000, -16, 2, 2048) pygame.mixer.init() pygame.mixer.set_num_channels(3) +pygame.mixer.stop() + intro = pygame.mixer.Sound("./assets/sounds/intro.mp3") menu = pygame.mixer.Sound("./assets/music/menu.mp3") @@ -17,6 +19,10 @@ bgm = [ ] sfx = { + "action": [pygame.mixer.Sound("./assets/sounds/gui/action.ogg")], + "back": [pygame.mixer.Sound("./assets/sounds/gui/back.ogg")], + "menu": [pygame.mixer.Sound("./assets/sounds/gui/menu.ogg")], + "save": [pygame.mixer.Sound("./assets/sounds/gui/save.ogg")], "glass": [ pygame.mixer.Sound("./assets/sounds/game/block_glass_1.ogg"), pygame.mixer.Sound("./assets/sounds/game/block_glass_2.ogg"), @@ -49,20 +55,38 @@ sfx = { } def play_intro(): + return pygame.mixer.Channel(0).play(intro) def play_music(): + return if not pygame.mixer.Channel(1).get_busy(): pygame.mixer.Channel(1).set_volume(0.5) pygame.mixer.Channel(1).play(random.choice(bgm)) def play_menu(force=False): + return if not pygame.mixer.Channel(1).get_busy() or force: pygame.mixer.Channel(1).set_volume(0.5) pygame.mixer.Channel(1).play(menu) def stop(channel=1): + return pygame.mixer.Channel(channel).stop() +def pause_music(): + return + pygame.mixer.Channel(1).pause() + +def unpause_music(): + return + pygame.mixer.Channel(1).unpause() + def play_sfx(id): - pygame.mixer.Channel(2).play(random.choice(sfx[id]))
\ No newline at end of file + return + pygame.mixer.Channel(2).play(random.choice(sfx[id])) + +def wait_for_sfx(): + return + while pygame.mixer.Channel(2).get_busy(): + pass
\ No newline at end of file |