本文整理汇总了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
示例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)
示例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()
示例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)
示例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"
示例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
示例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)
示例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
示例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()
示例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()
示例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)
示例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()
示例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
示例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),
]
示例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)