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


Python Menu类代码示例

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


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

示例1: run

 def run(self):
     
     #self.menu.run(self.screen,self.pointergroup)
     #Game.run(self.screen,self.pointergroup)
     
     clock = pygame.time.Clock()
     scenario = Scenario.Menu()
     scenario.load()
     
     #loop principale
     while True:
         for event in pygame.event.get():
             if event.type == (pygame.QUIT):
                 print "fine"
                 sys.exit()
                 
             if event.type == (pygame.KEYDOWN):
                 print event.dict
                 if event.dict['key'] == 27:
                     print "fine"
                     Menu.run(screen,pointergroup)
                     #sys.exit()
         if scenario.running == True:    
             scenario.Update(self.pointergroup,clock,event)
             scenario.Render(self.screen)
         if scenario.change == True:
             scenario = scenario.load()
         
         #Render.render(self.screen,scenario,self.pointergroup)
         clock.tick()
     return 0
开发者ID:Fabioamd87,项目名称:mojo,代码行数:31,代码来源:Engine.py

示例2: stage_select

def stage_select():
    # Screen
    screen = pygame.display.set_mode((SCREEN_WIDTH,SCREEN_HEIGHT))
    ACTUAL_STAGE
    #Background
    background = pygame.image.load(os.path.join('', 'images', 'menu_bg.jpg'))
    background = background.convert()
    
    #Cursor
    pygame.mouse.set_visible(False)
    cursor = Cursor(16,16,'images/cursor.png')
    
    #Put Here the Stages of the game
    stage1 = Option(100,150,250,327,'images/fase1_small.jpg','images/fase1.jpg',stage1_function,1.2,0.05,True)
    stage2 = Option(400,400,250,278,'images/fase2.jpg','images/fase2_big.jpg',stage2_function,1.2,0.05,True)
    # ...
    
    
    # Create menu
    select_menu = Menu()
    select_menu.append(stage1)
    select_menu.append(stage2)
    # ...
    
    select_menu.main_loop(cursor,screen,background)
开发者ID:r0qs,项目名称:chubby,代码行数:25,代码来源:Good_intentions.py

示例3: winner

def winner(name):
    pygame.init()
    pygame.mixer.music.load("sounds/winscreen.mp3")
    pygame.mixer.music.play(-1)
    screen = pygame.display.get_surface()                                   
    screen = pygame.display.set_mode((800, 600), pygame.RESIZABLE) 
    level = pygame.image.load("background/winScreen.jpg").convert()        
    levelRect = level.get_rect(center=(400, 300))
    screen.blit(level, (0, 0))
    myfont = pygame.font.Font("fonts/moonhouse.ttf", 50)
    winner = name + " Wins!!!"
    label = myfont.render(winner, 1, (0, 255, 0))
    textpos = label.get_rect()
    textpos.centerx = level.get_rect().centerx
    textpos.centery = level.get_rect().centery
    while 1:
        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
                keypressed = pygame.key.name(event.key)
                if keypressed == pygame.key.name(pygame.K_ESCAPE):
                    Menu.main()
                    sys.exit(0)
        screen.blit(level, (0,0))
        screen.blit(label, textpos)
        pygame.display.flip()
开发者ID:dieg08,项目名称:PyFighters-,代码行数:25,代码来源:WinScreen.py

示例4: drawFogOfWarOnMiniMap

 def drawFogOfWarOnMiniMap(self,mainScreen,index):
     rows, cols = len(self.fogOfWarBoard[index]), len(self.fogOfWarBoard[index][0])
     fogBlack = (1,1,1,220)
     for row in xrange(rows):
         for col in xrange(cols):
             if self.fogOfWarBoard[index][row][col] == 0:
                 Menu.drawMiniMapCell(mainScreen,row,col,fogBlack)
开发者ID:jeff95723,项目名称:Term_Project,代码行数:7,代码来源:map.py

示例5: menu

def menu(pantalla,X_Screen,Y_Screen):
	opcionEscogida=False
	menuJuego = Menu(ANCHO,ALTO)
	menuJuego.cargarImgMenu()
	pantalla.blit(menuJuego.obtenerImg(),(X_Screen,Y_Screen))
	pygame.display.flip()
	while True:
		tecla = pygame.key.get_pressed()
		tecla = pygame.key.get_pressed()
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				sys.exit()
			if tecla[K_DOWN]:
				menuJuego.flechaAbajo()
				imagen=menuJuego.obtenerImg()
				pantalla.blit(imagen,(0,0))
				pygame.display.flip()
			if tecla[K_UP]:
				menuJuego.flechaArriba()
				imagen=menuJuego.obtenerImg()
				pantalla.blit(imagen,(0,0))
				pygame.display.flip()
			if tecla[K_RETURN]:
				if(menuJuego.OpcionActual==0):
					dibujarNuevoJuego(pantalla,X_Screen,Y_Screen)
					print"jfdgkhfdg"			
开发者ID:luma2906,项目名称:GraficaVideoJuego,代码行数:26,代码来源:principal.py

示例6: __init__

 def __init__(self):
     self.pauseMenu = Menu()
     self.statsMenu = Menu()
     self.weaponMenu = Menu()
     self.armorMenu = Menu()
     self.promptMenu = Menu()
     self.rmin = 400
     self.rmax = 800
     self.bgtimer = random.randint(self.rmin, self.rmax)
     self.dirtimer = random.randint(self.rmin, self.rmax)
     self.max_chans = 100
     pygame.mixer.set_num_channels(self.max_chans)
     self.smanager = SoundManager(self.max_chans)
     amb = pygame.mixer.Sound('ambient2.ogg')
     self.ambch = pygame.mixer.Channel(self.smanager.get())
     br = pygame.mixer.Sound('charbreath.ogg')
     wk = pygame.mixer.Sound('charwalk.ogg')
     rn = pygame.mixer.Sound('charrun.ogg')
     gr = pygame.mixer.Sound('chargrunt.ogg')
     hw = pygame.mixer.Sound('hitwall2.ogg')
     hb = pygame.mixer.Sound('heartbeat.ogg')
     hbf = pygame.mixer.Sound('heartbeat_fast.ogg')
     
     pygame.mixer.Sound('armor_aquire.ogg')
     bgfx = [pygame.mixer.Sound('roar_distant.ogg'),\
             pygame.mixer.Sound('ambient3.ogg'),\
             pygame.mixer.Sound('bug_alien.ogg')]
     self.bgsound = RadarSound(bgfx, self.smanager.get())
     self.screen = pygame.display.get_surface()
     self.srect = self.screen.get_rect()
     self.bg = pygame.Surface((self.srect.width, self.srect.height))
     self.bg.fill((0, 75, 75))
     self.bgrect = self.bg.get_rect()
     self.fog = pygame.Surface((self.srect.width, self.srect.height))
     self.fog.fill((128, 128, 128))
     self.fogrect = self.fog.get_rect()
     self.fog.set_alpha(245)
     self.char = Char(self.smanager.get(), [wk, rn], self.smanager.get(), [br, gr, hw],\
              self.smanager.get(), [hb, hbf])
     self.weaponChannel = self.smanager.get()
     self.armorChannel = self.smanager.get()
     self.char.getWeapon(Katana(self.char, self.weaponChannel))
     self.char.getWeapon(Pistol(self.char, self.weaponChannel))
     self.char.equipWeapon(0)
     self.char.getArmor(lightArmor(self.armorChannel))
     self.char.equipArmor(0)
     self.chars = pygame.sprite.RenderUpdates(self.char)
     self.enemies = pygame.sprite.RenderUpdates()
     self.lmarks = pygame.sprite.RenderUpdates()
     self.dirfx = pygame.sprite.RenderUpdates()
     self.dirfxs = pygame.sprite.RenderUpdates()
     self.spawner = Spawner(self.char, self.smanager, self.enemies, self.lmarks,\
                            self.dirfx, self.dirfxs, self.weaponChannel, self.armorChannel)
     self.menuInit()
     self.ambch.set_volume(.5)
     self.ambch.play(amb, -1)
     self.clock = pygame.time.Clock()
     self.bgdis()
     pygame.display.flip
开发者ID:gcastellanos,项目名称:radar,代码行数:59,代码来源:worldClass.py

示例7: init

def init():
        #interaction clavier
        tty.setcbreak(sys.stdin.fileno())
        
        #cacher le curseur
        os.system('setterm -cursor off')        
        Menu.setCurrentWindow(menu, "mainMenu")
        Menu.show(menu)
开发者ID:Neopibox,项目名称:MDD,代码行数:8,代码来源:main.py

示例8: interact

def interact(game):
    if Game.getState(game) == 'menu':
        Menu.interact(game)
    elif Game.getState(game) == 'game':
        Game.interact(game)
    elif Game.getState(game) == 'quitGame':
        Game.quitGame(game)
    return
开发者ID:AllanDano,项目名称:PROJET-MDD_NMaillard_ADano,代码行数:8,代码来源:main.py

示例9: main

def main():
    pygame.init()
    main_surface = pygame.display.set_mode((1200, 900))
    pygame.display.set_caption("SyntaXError")

    while True:
        # game_intro(main_surface)                                      # begint de intro
        Menu.menu(main_surface)
        pygame.display.flip()
开发者ID:StefanVissers,项目名称:ProjectSyntaxError,代码行数:9,代码来源:Main.py

示例10: main

def main():
		
		os.environ["SDL_VIDEO_CENTERED"] = "1"
		pygame.init()
		tela = pygame.display.set_mode((1024, 600))
		musicaInicio = pygame.mixer.music.load("img/loop.ogg")
		pygame.mixer.music.play(-1)
		menu = Menu(tela)
		menu.inicioMenu()
开发者ID:diegolms,项目名称:pyquimica,代码行数:9,代码来源:main.py

示例11: interact

def interact(): 
        global direction, refresh, game, menu
       
        refresh = False
        #gestion des evenements clavier
        if isData():                                    #si une touche est appuyee
                refresh = True                
                key = sys.stdin.read(1)
                if Menu.gameWindow(menu):               # si on est sur le fenetre de jeu alors ...
                        Game.interact(game, settings, key)

                        if key == "p":
                                Menu.setCurrentWindow(menu, "pause")       # faire apparaitre le menu Pause
                else: 
                        if key == "z": 
                                Menu.changeSelectedButton(menu, "buttonUp")

                        elif key == "s":
                                Menu.changeSelectedButton(menu, "buttonDown")
                        
                        elif key == "d":
                                # Execute les commandes présentent dans la liste de commande à executer du bouton selectionne
                                buttonCmdList = Menu.getButtonList(menu, Menu.getIndexOfSelectedButton(menu, Menu.getButtonList(menu), Menu.getButtonSelected(menu,"name")),"cmd")
                                
                                for cmd in buttonCmdList:
                                        exec cmd
        
                if key == "\x1b": 
                        quit()                          # \x1b = touche echap / appel de la fonction qui permet de quitter le jeu
        
        while isData():
                sys.stdin.read(5)
开发者ID:Neopibox,项目名称:MDD,代码行数:32,代码来源:main.py

示例12: main

def main():
    # pygame initialization
    pygame.init()
    pygame.mixer.music.load('sounds/menu.mp3')
    pygame.mixer.music.play(-1)

    pygame.display.set_caption('PyFighters')
    pygame.mouse.set_visible(1)
    clock = pygame.time.Clock()
    
    
    
    
    # code for our menu 
    ourMenu = ("Play Online",
               "How to play",
               "Statistics",
               "Exit")
    myMenu = Menu(ourMenu)
    myMenu.drawMenu()
    pygame.display.flip()
    # main loop for event handling and drawing
    while 1:
        clock.tick(60)

    # Handle Input Events
        for event in pygame.event.get():
            myMenu.handleEvent(event)
            # quit the game if escape is pressed
            if event.type == QUIT:
                sys.exit(0)
            elif event.type == Menu.MENUCLICKEDEVENT:    
                if event.text == "Play Online":
                    time.sleep(1)
                    character = CharSelect.charselect()
                    print "Just Waiting..."
                    InitScript.main(socketInit(), character)
                elif event.text == "How to play":
                    Settings.settings()
                elif event.text == "Local Play":
                    Script.main()
                elif event.text == "Exit":
                    sys.exit(0)
            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                myMenu.activate()
                sys.exit(0)

                
        if myMenu.isActive():
            myMenu.drawMenu()
               
        
        pygame.display.flip()
开发者ID:dieg08,项目名称:PyFighters-,代码行数:53,代码来源:Menu.py

示例13: interact

def interact(game):
    if Game.getState(game) == 'menu':
        Menu.interact(game)
    elif Game.getState(game) == 'game':
        Game.interact(game)
    elif Game.getState(game) == 'editor':
        editor.start()
        Game.setState('menu', game)
        Game.setLevel(Level.create(1, 'levels.txt'), game)
    elif Game.getState(game) == 'quitGame':
        Game.quitGame(game)
    return
开发者ID:NoMaillard,项目名称:PROJET-MDD_NMaillard_ADano,代码行数:12,代码来源:main.py

示例14: common_net_options

 def common_net_options(menu_is_enabled, leave_menu):
     return [
         Menu.Splitter(),
         Menu.EventOption(enabled_func = Menu.always,
                          action = game.save_net_config,
                          text = Menu.text('Save network options'),
                          keys = [],
                          description = 'Save options to net_config.py'),
         Menu.Splitter(),
         Menu.EventOption(enabled_func = menu_is_enabled,
                          action = leave_menu,
                          text = Menu.text('Leave Menu'),
                          keys = [config.CANCEL_KEY, config.MENU_KEY],
                          steal_key = True),
     ]
开发者ID:Peaker,项目名称:pyun,代码行数:15,代码来源:menus.py

示例15: changeKey

def changeKey(keyName):        
        while not isData():     # Tant qu'il n'y a pas d'autres touche de rentrée
                Menu.setButtonSelected(menu, "state", True)
                Menu.showButtons(menu)
                
        Menu.setButtonSelected(menu, "state", False)
        read = sys.stdin.read(1)  
        canChange = True
        for key in settings:
                if read == settings[key] or read == 'p':
                        canChange = False
        if canChange:
                Settings.setKey(settings,keyName,read)
                Menu.setButtonName(menu, read)
        Menu.showButtons(menu)
开发者ID:Neopibox,项目名称:MDD,代码行数:15,代码来源:main.py


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