feat:update music and sound

This commit is contained in:
Kylin_on_Mac 2023-11-09 14:11:13 +08:00
parent d7343e098a
commit c777814018
9 changed files with 12 additions and 7 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
asset/sounds/fail.mp3 Normal file

Binary file not shown.

BIN
asset/sounds/lv_down.mp3 Normal file

Binary file not shown.

BIN
asset/sounds/lv_up.mp3 Normal file

Binary file not shown.

BIN
asset/sounds/pass.mp3 Normal file

Binary file not shown.

View File

@ -185,7 +185,8 @@ class EasyGame(PaiaGame):
if self.is_passed:
self._level += 1
self.sound_controller.play_cheer()
else:
self.sound_controller.play_fail()
self._init_game()

View File

@ -22,11 +22,12 @@ class SoundController():
pygame.mixer.init()
pygame.mixer.music.load(path.join(MUSIC_PATH, "bgm.wav"))
pygame.mixer.music.set_volume(0.6)
self._eating_good = pygame.mixer.Sound(path.join(SOUND_PATH, "Coin.wav"))
self._eating_bad = pygame.mixer.Sound(path.join(SOUND_PATH, "Low Boing.wav"))
self._cheer = pygame.mixer.Sound(path.join(SOUND_PATH, "Cheer.wav"))
self._lv_up = pygame.mixer.Sound(path.join(SOUND_PATH, "lv_up.wav"))
self._lv_down = pygame.mixer.Sound(path.join(SOUND_PATH, "lv_down.wav"))
self._eating_good = pygame.mixer.Sound(path.join(SOUND_PATH, "eat_good_food.mp3"))
self._eating_bad = pygame.mixer.Sound(path.join(SOUND_PATH, "eat_bad_food.mp3"))
self._pass = pygame.mixer.Sound(path.join(SOUND_PATH, "pass.mp3"))
self._fail = pygame.mixer.Sound(path.join(SOUND_PATH, "fail.mp3"))
self._lv_up = pygame.mixer.Sound(path.join(SOUND_PATH, "lv_up.mp3"))
self._lv_down = pygame.mixer.Sound(path.join(SOUND_PATH, "lv_down.mp3"))
except Exception:
self._is_sound_on = False
@ -43,9 +44,12 @@ class SoundController():
self._eating_bad.play()
@sound_enabled
def play_cheer(self):
self._cheer.play()
self._pass.play()
@sound_enabled
def play_fail(self):
self._fail.play()
@sound_enabled
def play_lv_up(self):
self._lv_up.play()