本文整理汇总了Python中Menu.show_menu方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.show_menu方法的具体用法?Python Menu.show_menu怎么用?Python Menu.show_menu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Menu
的用法示例。
在下文中一共展示了Menu.show_menu方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enterName
# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import show_menu [as 别名]
def enterName(self):
# Getting player name
font = self.game.font
textplease = font.render("Please type your name now", 1, (0,0,0))
textpleasepos = (self.width/4, self.height/2-70)
background = pygame.image.load('images/title.png').convert_alpha()
self.game.screen.blit(background,(0,0))
self.game.screen.blit(textplease, textpleasepos)
pygame.display.flip()
getname=True
current_string = []
while getname:
if len(current_string)>=25:
getname=False
inkey = get_key()
if inkey == K_BACKSPACE:
current_string = current_string[0:-1]
elif inkey == K_RETURN and len(current_string)>=1: # change this when we don't want blank names
getname=False
elif inkey == K_MINUS:
current_string.append("_")
elif inkey == K_SPACE:
current_string.append(" ")
elif inkey == K_RSHIFT or inkey == K_LSHIFT or inkey >127 or inkey < 97:
continue
elif inkey>=97 and inkey <= 127:
current_string.append(chr(inkey-32))
else:
current_string.append(chr(inkey))
display_box(self.game.screen, string.join(current_string,""))
name=string.join(current_string,"")
saveScore(name,self.score)
textname = font.render(name, 1, (0,0,0))
textnamepos = (0,self.height-60)
textscore = font.render("Score: " + str(self.score), 1, (0,0,0))
textscorepos = (0,self.height-30)
Menu.show_menu()
示例2:
# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import show_menu [as 别名]
import pygame
import Menu
Menu.show_menu()
# The below may be found in Menu.py under the execute function
'''
from pygame import *
from sys import *
from Game import *
g=Game()
while g.cont:
g.clock.tick(30)
g.process_events()
g.update()
g.collisions()
g.draw()
pygame.display.flip()
pygame.quit()
'''