class RockSlide: def __init__(self): pygame.init() pygame.mouse.set_visible(False) pygame.display.set_caption("Golem") self.screen = pygame.display.set_mode(GameConstants.SCREEN_SIZE, pygame.DOUBLEBUF, 32) self.screen.fill(GameConstants.WHITE) self.clock = pygame.time.Clock() pygame.mixer.init() #pygame.mixer.music.load("Assets\\level_music.mp3") self.__game_scene = GameScene() self.__main_menu_scene = MainMenuScene() self.__game_over_scene = GameOverScene() self.__good_ending_scene = GoodEndingScene() self.__bad_ending_scene = BadEndingScene() #pygame.mixer.music.play(-1) self.__game_scene.start() self.__current_scene = self.__game_scene def start(self): done = False while not done: self.clock.tick(60) self.__current_scene.draw(self.screen) pygame.display.flip() events = pygame.event.get() for event in events: if event.type == pygame.QUIT: done = True state = self.__current_scene.update() # -- switch the game state if necessary if state == GameStatus.TRANSITION_MAIN_MENU: self.__current_scene = self.__main_menu_scene elif state == GameStatus.TRANSITION_GAME_OVER: self.__current_scene = self.__game_over_scene elif state == GameStatus.TRANSITION_GAME: self.__game_scene.start() self.__current_scene = self.__game_scene elif state == GameStatus.TRANSITION_GOOD_ENDING: self.__current_scene = self.__good_ending_scene elif state == GameStatus.TRANSITION_BAD_ENDING: self.__current_scene = self.__bad_ending_scene elif state == GameStatus.STATUS_QUIT: done = True
def __init__(self): pygame.init() pygame.mouse.set_visible(False) pygame.display.set_caption("Golem") self.screen = pygame.display.set_mode(GameConstants.SCREEN_SIZE, pygame.DOUBLEBUF, 32) self.screen.fill(GameConstants.WHITE) self.clock = pygame.time.Clock() pygame.mixer.init() #pygame.mixer.music.load("Assets\\level_music.mp3") self.__game_scene = GameScene() self.__main_menu_scene = MainMenuScene() self.__game_over_scene = GameOverScene() self.__good_ending_scene = GoodEndingScene() self.__bad_ending_scene = BadEndingScene() #pygame.mixer.music.play(-1) self.__game_scene.start() self.__current_scene = self.__game_scene