From 03afd42fdcd52e4a827016828c4ad286de320078 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Thu, 31 Aug 2023 22:47:58 +0200 Subject: Updated 5 files, added 2 files and deleted 337 files (automated) --- src/audio.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/audio.py') diff --git a/src/audio.py b/src/audio.py index ceb7cad..17ae5ef 100644 --- a/src/audio.py +++ b/src/audio.py @@ -6,6 +6,8 @@ pygame.mixer.init() pygame.mixer.set_num_channels(3) intro = pygame.mixer.Sound("./assets/sounds/intro.mp3") +menu = pygame.mixer.Sound("./assets/music/menu.mp3") + bgm = [ pygame.mixer.Sound("./assets/music/bgm1.mp3"), pygame.mixer.Sound("./assets/music/bgm2.mp3"), @@ -54,5 +56,13 @@ def play_music(): pygame.mixer.Channel(1).set_volume(0.5) pygame.mixer.Channel(1).play(random.choice(bgm)) +def play_menu(force=False): + 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): + pygame.mixer.Channel(channel).stop() + def play_sfx(id): pygame.mixer.Channel(2).play(random.choice(sfx[id])) \ No newline at end of file -- cgit