diff options
author | RaindropsSys <contact@minteck.org> | 2023-08-31 22:47:58 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-08-31 22:47:58 +0200 |
commit | 03afd42fdcd52e4a827016828c4ad286de320078 (patch) | |
tree | 0cb77209fdb1d4d192afa2ac6d6c3ada0074661b /src/audio.py | |
parent | e54ac640f1d3f7071a48032e924b04529cbd358f (diff) | |
download | blocks-03afd42fdcd52e4a827016828c4ad286de320078.tar.gz blocks-03afd42fdcd52e4a827016828c4ad286de320078.tar.bz2 blocks-03afd42fdcd52e4a827016828c4ad286de320078.zip |
Updated 5 files, added 2 files and deleted 337 files (automated)
Diffstat (limited to 'src/audio.py')
-rw-r--r-- | src/audio.py | 10 |
1 files changed, 10 insertions, 0 deletions
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 |