feat: add Cheer.wav
This commit is contained in:
parent
55b195ae14
commit
4cebd4e2fe
Binary file not shown.
15
src/game.py
15
src/game.py
|
@ -75,6 +75,7 @@ class EasyGame(PaiaGame):
|
||||||
with open(os.path.join(LEVEL_PATH, "001.json")) as f:
|
with open(os.path.join(LEVEL_PATH, "001.json")) as f:
|
||||||
game_params = json.load(f)
|
game_params = json.load(f)
|
||||||
self._level = 1
|
self._level = 1
|
||||||
|
self._level_file=None
|
||||||
self._set_game_params(game_params)
|
self._set_game_params(game_params)
|
||||||
|
|
||||||
def _set_game_params(self, game_params):
|
def _set_game_params(self, game_params):
|
||||||
|
@ -164,16 +165,20 @@ class EasyGame(PaiaGame):
|
||||||
|
|
||||||
if self.is_running:
|
if self.is_running:
|
||||||
status = GameStatus.GAME_ALIVE
|
status = GameStatus.GAME_ALIVE
|
||||||
elif self.score > self._score_to_pass:
|
elif self.is_passed:
|
||||||
status = GameStatus.GAME_PASS
|
status = GameStatus.GAME_PASS
|
||||||
else:
|
else:
|
||||||
status = GameStatus.GAME_OVER
|
status = GameStatus.GAME_OVER
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
|
|
||||||
|
if self.is_passed:
|
||||||
|
self.sound_controller.play_cheer()
|
||||||
|
|
||||||
if self._level_file:
|
if self._level_file:
|
||||||
pass
|
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
|
# win and use level will enter next level
|
||||||
self._level += 1
|
self._level += 1
|
||||||
self.set_game_params_by_level(self._level)
|
self.set_game_params_by_level(self._level)
|
||||||
|
@ -182,6 +187,10 @@ class EasyGame(PaiaGame):
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_passed(self):
|
||||||
|
return self.score > self._score_to_pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_running(self):
|
def is_running(self):
|
||||||
return self.frame_count < self._frame_limit
|
return self.frame_count < self._frame_limit
|
||||||
|
@ -247,7 +256,7 @@ class EasyGame(PaiaGame):
|
||||||
"player": get_ai_name(0),
|
"player": get_ai_name(0),
|
||||||
"rank": 1,
|
"rank": 1,
|
||||||
"score": self.score,
|
"score": self.score,
|
||||||
"passed": self.score > self._score_to_pass
|
"passed": self.is_passed
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ class SoundController():
|
||||||
pygame.mixer.music.set_volume(0.6)
|
pygame.mixer.music.set_volume(0.6)
|
||||||
self._eating_good = pygame.mixer.Sound(path.join(SOUND_PATH, "Coin.wav"))
|
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._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:
|
except Exception:
|
||||||
self._is_sound_on = False
|
self._is_sound_on = False
|
||||||
|
|
||||||
|
@ -38,3 +39,6 @@ class SoundController():
|
||||||
@sound_enabled
|
@sound_enabled
|
||||||
def play_eating_bad(self):
|
def play_eating_bad(self):
|
||||||
self._eating_bad.play()
|
self._eating_bad.play()
|
||||||
|
@sound_enabled
|
||||||
|
def play_cheer(self):
|
||||||
|
self._cheer.play()
|
||||||
|
|
Loading…
Reference in New Issue