class StartBoo(StartListener): def __init__(self): with open(GameController.SETTINGS, "r") as file: jsonFile = json.loads(file.read()) self.__song = jsonFile["booSound"] folder = jsonFile["musicFolder"] self.__music = Music(folder) def start(self): self.__music.play(self.__song)
class RestartGoalSound(Game.RestartGame): def __init__(self, game): Game.RestartGame.__init__(self, game) #Default musicFolder = "Music" self.__restartSound = "restart.mp3" if os.path.exists(GameController.SETTINGS): with open(GameController.SETTINGS, "r") as file: jsonFile = json.loads(file.read()) musicFolder = jsonFile["musicFolder"] self.__restartSound = jsonFile["restartSound"] self.__music = Music(musicFolder) def motion(self): Game.RestartGame.motion(self) self.__music.play(self.__restartSound) print("Restarting score!")
class StopGame(Game.StopGame): def __init__(self, game): Game.StopGame.__init__(self, game) #Default musicFolder = "Music" self.__stopSound = "restart.mp3" if os.path.exists(GameController.SETTINGS): with open(GameController.SETTINGS, "r") as file: jsonFile = json.loads(file.read()) musicFolder = jsonFile["musicFolder"] self.__stopSound = jsonFile["powerOffSound"] self.__music = Music(musicFolder) def motion(self): Game.StopGame.motion(self) self.__music.play(self.__stopSound) #W8 to finish the sound while self.__music.isPlayingMusic(): time.sleep(0.1) print("PowerOff raspberry!")
class VisitorGoalSound(Game.VisitorGoal): def __init__(self, game): Game.VisitorGoal.__init__(self, game) #Default musicFolder = "Music" if os.path.exists(GameController.SETTINGS): with open(GameController.SETTINGS, "r") as file: jsonFile = json.loads(file.read()) musicFolder = jsonFile["musicFolder"] self.finSong = jsonFile['restartSound'] self.music = Music(musicFolder) def motion(self): Game.VisitorGoal.motion(self) # finish = self.game.gameFinish() # if not finish: if not self.game.gameFinish(): print("GOOL visitant!") self.music.random() else: self.music.play(self.finSong)