Example #1
0
 def __init__(self):
     pygame.init()
     self.font = pygame.font.SysFont('sans-serif', 18, True)
     self.surface = pygame.display.set_mode(self.SCREEN_SIZE, 0, 32)
     self.state = 'intro'
     self.hiscores = Score.read_high_score()
     self.menu = Menu(("Start game", "Quit"))
     pygame.mixer.music.load(self.MUSIC_FILE)
     pygame.mixer.music.play(-1)
Example #2
0
 def start(self):
     while True:
         if self.state == 'intro':
             # Show the intro and when it's done we move directly to game state
             intro = Intro(pygame, self.surface);
             new_state = intro.show()
             self.state = new_state
         elif self.state == 'menu':
             # Show the menu and run the menu loop
             self.hiscores = Score.read_high_score()
             self.show_menu()
         elif self.state == 'game':
             # Run a game and run the game loop
             self.load_level()
             self.game_loop()
         elif self.state == 'quit':
             # Quit, we're done.
             pygame.quit()
             sys.exit()