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


Python Menu.update方法代码示例

本文整理汇总了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()
开发者ID:r0qs,项目名称:chubby,代码行数:49,代码来源:Menu_example.py

示例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)
开发者ID:nickihilker,项目名称:frogger-1,代码行数:64,代码来源:Program.py

示例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
开发者ID:mionick,项目名称:Tetris-Pygame,代码行数:33,代码来源:main.py


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