diff --git a/asset/sounds/Cheer.wav b/asset/sounds/Cheer.wav new file mode 100644 index 0000000..4bc9782 Binary files /dev/null and b/asset/sounds/Cheer.wav differ diff --git a/src/game.py b/src/game.py index 26452f4..3b916df 100644 --- a/src/game.py +++ b/src/game.py @@ -75,6 +75,7 @@ class EasyGame(PaiaGame): with open(os.path.join(LEVEL_PATH, "001.json")) as f: game_params = json.load(f) self._level = 1 + self._level_file=None self._set_game_params(game_params) def _set_game_params(self, game_params): @@ -164,16 +165,20 @@ class EasyGame(PaiaGame): if self.is_running: status = GameStatus.GAME_ALIVE - elif self.score > self._score_to_pass: + elif self.is_passed: status = GameStatus.GAME_PASS else: status = GameStatus.GAME_OVER return status def reset(self): + + if self.is_passed: + self.sound_controller.play_cheer() + if self._level_file: pass - elif self.score > self._score_to_pass and self._level != -1: + elif self.is_passed and self._level != -1: # win and use level will enter next level self._level += 1 self.set_game_params_by_level(self._level) @@ -182,6 +187,10 @@ class EasyGame(PaiaGame): pass + @property + def is_passed(self): + return self.score > self._score_to_pass + @property def is_running(self): return self.frame_count < self._frame_limit @@ -247,7 +256,7 @@ class EasyGame(PaiaGame): "player": get_ai_name(0), "rank": 1, "score": self.score, - "passed": self.score > self._score_to_pass + "passed": self.is_passed } ] diff --git a/src/sound_controller.py b/src/sound_controller.py index b6688b5..284109d 100644 --- a/src/sound_controller.py +++ b/src/sound_controller.py @@ -24,6 +24,7 @@ class SoundController(): 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")) except Exception: self._is_sound_on = False @@ -38,3 +39,6 @@ class SoundController(): @sound_enabled def play_eating_bad(self): self._eating_bad.play() + @sound_enabled + def play_cheer(self): + self._cheer.play()