From 6a20ab31ef4d9f6bb0e008b9f1b8d3fbeb6bd956 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Sat, 2 Sep 2023 15:32:03 +0200 Subject: Updated 13 files and added 2 files (automated) --- src/audio.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/audio.py') diff --git a/src/audio.py b/src/audio.py index baba6da..1d8f725 100644 --- a/src/audio.py +++ b/src/audio.py @@ -1,6 +1,8 @@ import pygame import random +enable_audio = False + pygame.mixer.pre_init(48000, -16, 2, 2048) pygame.mixer.init() pygame.mixer.set_num_channels(3) @@ -55,38 +57,46 @@ sfx = { } def play_intro(): - return + if not enable_audio: + return pygame.mixer.Channel(0).play(intro) def play_music(): - return + if not enable_audio: + 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 enable_audio: + 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 + if not enable_audio: + return pygame.mixer.Channel(channel).stop() def pause_music(): - return + if not enable_audio: + return pygame.mixer.Channel(1).pause() def unpause_music(): - return + if not enable_audio: + return pygame.mixer.Channel(1).unpause() def play_sfx(id): - return + if not enable_audio: + return pygame.mixer.Channel(2).play(random.choice(sfx[id])) def wait_for_sfx(): - return + if not enable_audio: + return while pygame.mixer.Channel(2).get_busy(): - pass \ No newline at end of file + pass -- cgit