本文整理汇总了Python中Menu.update方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.update方法的具体用法?Python Menu.update怎么用?Python Menu.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Menu
的用法示例。
在下文中一共展示了Menu.update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import update [as 别名]
def main():
width = 1024
height = 768
pygame.display.init
menu_screen = pygame.display.set_mode((width,height))
# 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')
#Options in menu
new_game = Option(200,200,173,89,'images/little.png','images/big.png',new_game_function, 1.42)
# Menu
menu = Menu()
menu.append(new_game)
menu_screen.blit(background, (0, 0))
cursor.draw(menu_screen)
menu.draw(menu_screen)
pygame.display.flip()
# Event loop
while 1:
menu.update(cursor)
for event in pygame.event.get():
if event.type == QUIT:
pygame.display.quit
sys.exit()
if event.type == KEYDOWN and event.key == K_ESCAPE:
running = False
return
elif event.type == MOUSEMOTION:
pygame.mouse.get_pos()
cursor.update()
elif event.type == MOUSEBUTTONDOWN:
menu.activate()
menu_screen.blit(background, (0, 0))
menu.draw(menu_screen)
cursor.draw(menu_screen)
pygame.display.flip()
示例2: Program
# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import update [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)
示例3: GetEvents
# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import update [as 别名]
GetEvents()
InputHandler.update()
#frame business
frames+=1
if (pygame.time.get_ticks() - startTime >= 1000):
actualFPS = frames
frames=0
startTime = pygame.time.get_ticks()
fps_image = font15.render(str(actualFPS), 1, (255,255,255))
#UPDATE===============================================
#MENU STATE======================================
if (current_state == GameState.MENU):
Menu.update(milliseconds)
if (InputHandler.rotate_button != 0):
Menu.cursor_pos_up()
if (InputHandler.down_button):
Menu.cursor_pos_down()
if (InputHandler.accept_button or InputHandler.drop_button):
current_state = Menu.items[Menu.cursor_pos].attribute
elif (current_state == GameState.PLAYING):
#PLAYING STATE====================================
if board.active == None:
board.create()
switched = False
sinceYUpdate = 0