コード例 #1
0
 def handleEvent(self, event):
     if event.type == KEYDOWN:
         if event.key == K_ESCAPE:
             self.running = False
             GameData.playSound(CLICK_SFX)
     elif event.type == MOUSEBUTTONDOWN:
         if event.button == LEFT_MOUSE:
             selection = self.selectedButton()
             if selection == self.main_menu_button:
                 self.running = False
コード例 #2
0
 def _handleInput(self):
     for event in pygame.event.get():
         if event.type == QUIT:
             sys.exit(0)
         elif event.type == KEYDOWN:
             if event.key == K_m:
                 GameData.toggleMusic()
         elif event.type == MOUSEBUTTONDOWN:
             if event.button == LEFT_MOUSE and self.selectedButton():
                 GameData.playSound(CLICK_SFX)
         self.handleEvent(event)
コード例 #3
0
    def _update(self, time_passed):
        pre_selected = self.selectedButton()
            
        self.buttons.update()
        
        post_selected = self.selectedButton()
            
        # Play sound when the mouse enters a button or enters a different button
        if post_selected and pre_selected != post_selected:
            GameData.playSound(ROLLOVER_SFX)

        self.update(time_passed)
コード例 #4
0
 def handleEvent(self, event):
     if event.type == KEYDOWN:
         if event.key == K_ESCAPE:
             self.running = False
             GameData.playSound(CLICK_SFX)
     elif event.type == MOUSEBUTTONDOWN:
         if event.button == LEFT_MOUSE:
             selection = self.selectedButton()
             self.delay() # Don't switch menus instantly
             if selection == self.start_button:
                 #color = self.color_choice_window.run()
                 #level, points = self.game_window.run(color)
                 #self.high_scores_window.run(level, points)
                 pass
             elif selection == self.instructions_button:
                 self.instructions_window.run()
             elif selection == self.highscores_button:
                 temp_level = 19 #TODO: remove when done testing
                 temp_points = 2
                 self.high_scores_window.run(temp_level, temp_points)
             elif selection == self.quit_button:
                 self.running = False
             # Must reset caption if another window changed it
             pygame.display.set_caption(self.caption)