本文整理汇总了Python中Menu.handleInput方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.handleInput方法的具体用法?Python Menu.handleInput怎么用?Python Menu.handleInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Menu
的用法示例。
在下文中一共展示了Menu.handleInput方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Program
# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import handleInput [as 别名]
class Program():
# Booleans to distinguish which game mode you're playing
isClassicMode = False
# Class to handle gameplay in classic mode
classicMode = MainGame(WIDTH, HEIGHT)
# The game menu
menu = Menu(WIDTH, HEIGHT)
# The screen, for to drawz stuff on
screen = pygame.display.set_mode([WIDTH, HEIGHT])
# The clock, used to regulate frame rate
clock = pygame.time.Clock()
def __init__(self):
pygame.init()
def execute(self):
while 1:
# The menu was just closed
# Start the game
if not self.menu.is_open() and not self.isClassicMode:
self.isClassicMode = True
self.menu.stopMusic()
self.classicMode.startGame()
# The game ended, go back to the menu and reset the game
if self.classicMode.is_over():
self.isClassicMode = False
self.classicMode.endGame()
self.classicMode = MainGame(WIDTH, HEIGHT)
self.menu = Menu(WIDTH, HEIGHT)
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if self.isClassicMode:
self.classicMode.handleInput(event)
else:
self.menu.handleInput(event)
if self.isClassicMode and not self.classicMode.is_paused():
self.classicMode.play()
else:
self.menu.update()
self.screen.fill([0, 0, 0])
if self.isClassicMode:
self.classicMode.draw()
else:
self.menu.draw()
pygame.display.flip()
# regulate the frame rate to 60 fps
self.clock.tick(60)