当前位置: 首页>>代码示例>>Python>>正文


Python Menu.down方法代码示例

本文整理汇总了Python中menu.Menu.down方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.down方法的具体用法?Python Menu.down怎么用?Python Menu.down使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在menu.Menu的用法示例。


在下文中一共展示了Menu.down方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import down [as 别名]
def main():
    ser = serial.Serial('/dev/ttyAMA0', 7600, timeout=0)

    menu = Menu(MENU_STRUCTURE, 20, 4, output='lcd')
    menu.show()

    while True:
        data = ser.read(8).strip()

        if data:
            if data == 'c':     # clockwise
                menu.down()
            elif data == 'a':   # anti-clockwise
                menu.up()
            elif data == 'p':   # press
                menu.select()
            menu.show()
        sleep(0.01)
开发者ID:damianmoore,项目名称:hub-ui,代码行数:20,代码来源:service.py

示例2: main

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import down [as 别名]
def main():
    menu = Menu(MENU_STRUCTURE, 20, 4, output='terminal')

    def show():
        for i in range(20):
            print('')
        menu.show()

    show()
    kgen = getch(0.1)

    while True:
        key = kgen.next()

        if key:
            if key == 'B':
                menu.down()
            elif key == 'A':
                menu.up()
            elif key in [' ', '\n']:
                menu.select()
            show()
开发者ID:damianmoore,项目名称:hub-ui,代码行数:24,代码来源:simulator.py

示例3: __init__

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import down [as 别名]

#.........这里部分代码省略.........
            for lifebar in self.ui_lifebar:
                screen = lifebar[1].draw(screen)
        return screen

    # Giant Tree of Input parsing!

    def on_event(self, event):
        if self.menu_flag:
            self.menu_event(event)
        else:
            if hasattr(self, 'player'):
                self.game_event(event)
            else:
                print("Dropped Command.")
                    

    def menu_event(self, event):
        if event.type == pygame.QUIT:
           self._running = False
        if event.type == KEYDOWN:
            if event.key == K_LEFT:
                #Left
                pass
            if event.key == K_RIGHT:
                #Right
                pass
            if event.key == K_UP:
                #Up
                pass
            if event.key == K_DOWN:
                #Down
                pass
            if event.key == ord('x'):
                #x
                pass
            if event.key == ord('z'):
                #z
                pass
        if event.type == KEYUP:
            if event.key == K_ESCAPE:
                self.exit_game()
            if event.key == K_LEFT:
                #Left
                self.main_menu.up()
                self.current_level = [self.main_menu.selected_name(), 0, 0, "R"]
            if event.key == K_RIGHT:
                #Right
                self.main_menu.down()
                self.current_level = [self.main_menu.selected_name(), 0, 0, "R"]
            if event.key == K_UP:
                #Up
                self.main_menu.up()
                self.current_level = [self.main_menu.selected_name(), 0, 0, "R"]
            if event.key == K_DOWN:
                #Down
                self.main_menu.down()
                self.current_level = [self.main_menu.selected_name(), 0, 0, "R"]
            if event.key == ord('z'):
                self.load_level(self.current_level)

    def game_event(self, event):
        if event.type == pygame.QUIT:
           self._running = False
        if event.type == KEYDOWN:
            if event.key == K_LEFT:
                self.player.go_left()
            if event.key == K_RIGHT:
                self.player.go_right()
            if event.key == K_UP:
                self.player.go_up(self.ladder_sprite_list)
            if event.key == K_DOWN:
                self.player.go_down(self.ladder_sprite_list)
            if event.key == ord('x'):
                self.player.jump()
            if event.key == ord('z'):
                self.add_bullet(self.player.shoot())
        if event.type == KEYUP:
            if event.key == K_ESCAPE:
                self.exit_game()
            if event.key == K_LEFT:
                self.player.stop(self.ladder_sprite_list, 'left')
            if event.key == K_RIGHT:
                self.player.stop(self.ladder_sprite_list, 'right')
            if event.key == K_UP:
                self.player.stop(self.ladder_sprite_list, 'up')
            if event.key == K_DOWN:
                self.player.stop(self.ladder_sprite_list, 'down')
            if event.key == ord('x'):
                pass
            if event.key == ord('z'):
                self.player.stop_shoot()
            if event.key == ord('q'):
                if self._pause:
                    self.resume()
                else:
                    self.pause()
            if event.key == ord('r'):
                if self._debug:
                    self.main_menu.load_json()
                    self.load_level(self.current_level)
开发者ID:LordHamu,项目名称:RunNGun,代码行数:104,代码来源:game.py

示例4: Game

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import down [as 别名]

#.........这里部分代码省略.........
        # -----------------------------------------------
        
    def handle(self,event):
    
        # some flags (this could be re-done in a better way, but for now it works)
        wasPressedNow = 0 # this is for some stupid hack, see below
        # Menu ===============================================================
        if self.gameState == "menu":
        
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            if event.type == pygame.KEYDOWN: 
                if event.key == pygame.K_SPACE or event.key == pygame.K_RETURN:
                    if self.menu.press() == 3:     # play pressed
                        self.gameState = "game"    # begin game
                    elif self.menu.press() == 2:   # volume pressed
                        self.gameState = "volume"  # show volume menu
                        wasPressedNow = 1
                        self.volumeBack = 1
                    elif self.menu.press() == 1:   # credits pressed
                        self.gameState = "credits" # show credits
                        wasPressedNow = 1 # stupid hack to prevent event from being
                                          # read here and in the credits
                                          # probably the best solution would be to change
                                          # the way everything is structured
                                          # but this proved to be easier
                    elif self.menu.press() == 0: # quit pressed
                        pygame.quit()
                        sys.exit()
                    else:
                        pass # throw exception
                if event.key == pygame.K_DOWN:
                    self.menu.down()
                if event.key == pygame.K_UP:
                    self.menu.up()
        #  ===================================================================
        
        # Pause===============================================================
        if self.gameState == "pause":
        
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            if event.type == pygame.KEYDOWN: 
                if event.key == pygame.K_SPACE or event.key == pygame.K_RETURN:
                    if self.pause.press() == 3:   # continue pressed
                        self.gameState = "game"   # change state back to game
                    elif self.pause.press() == 2: # restart pressed
                        self.__init__()           # return to initial state
                        self.gameState = "game"   # change state back to game
                    elif self.pause.press() == 1:   # volume pressed
                        self.gameState = "volume"  # show volume menu
                        self.volumeBack = 0
                        wasPressedNow = 1
                    elif self.pause.press() == 0: # quit pressed
                        pygame.quit()
                        sys.exit()
                    else:
                        pass # throw exception
                if event.key == pygame.K_DOWN:
                    self.pause.down()
                if event.key == pygame.K_UP:
                    self.pause.up()
        #  ===================================================================
         
开发者ID:aalopes,项目名称:cometZ,代码行数:69,代码来源:core.py


注:本文中的menu.Menu.down方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。