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


Python Arrow.draw方法代码示例

本文整理汇总了Python中arrow.Arrow.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Arrow.draw方法的具体用法?Python Arrow.draw怎么用?Python Arrow.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在arrow.Arrow的用法示例。


在下文中一共展示了Arrow.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: menu

# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import draw [as 别名]
def menu(window, clock):

    arrow_right = Arrow("right", window.get_size())
    arrow_left = Arrow("left", window.get_size())

    loop = True

    while loop:
        for event in pygame.event.get():
            if event.type == QUIT:
                loop = False

            if event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    loop = False
                if event.key == K_RIGHT:
                    print "right"
                    arrow_right.big = True
                if event.key == K_LEFT:
                    print "left"
                    arrow_left.big = True

        window.fill((30,130,184))
        arrow_right.draw(window)
        arrow_left.draw(window)
        pygame.display.flip()
        clock.tick(30)
开发者ID:rmonin,项目名称:dung-console,代码行数:29,代码来源:menu.py

示例2: scnene_game

# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import draw [as 别名]
def scnene_game( gameDisplay ):
	# create game object
	# map
	play_map = GameMap(res.position_game_map, res.size_game_map, res.color_map,
						 res.size_grid, res.game_map_grids, 
						 res.width_game_map_wall, res.color_wall)
	play_map.kit_reset( res.kit_max, res.kit_freq )
	play_map.kit_gen()
	play_map.kit_gen()
	
	# player arrow
	arrow_p1 = Arrow(res.size_arrow, play_map.grid_center(res.grid_position_start_p1), (1,0), 2, res.speed_max, res.color_p1)
	arrow_p2 = Arrow(res.size_arrow, play_map.grid_center(res.grid_position_start_p2), (-1,0), 2, res.speed_max, res.color_p2)
	
	# player panel
	bar_p1 = PowerBar( res.position_panel_p1+res.size_panel_p1, res.speed_max, res.color_p1, (0,0,0) )
	bar_p2 = PowerBar( res.position_panel_p2+res.size_panel_p2, res.speed_max, res.color_p2, (0,0,0) )

	panel_p1 = PlayerPanel( res.position_panel_p1, res.size_panel_p1, res.color_p1 )
	panel_p1.set_item_slot( res.slot_layout )
	panel_p1.set_player( arrow_p1 )
	panel_p1.set_power_bar( bar_p1 )

	panel_p2 = PlayerPanel( res.position_panel_p2, res.size_panel_p2, res.color_p2 )
	panel_p2.set_item_slot( res.slot_layout )
	panel_p2.set_player( arrow_p2 )
	panel_p2.set_power_bar( bar_p2 )
	
	# add object to game
	gameArrowList = []
	gameArrowList.append( ArrowInGame(arrow_p1) )
	gameArrowList.append( ArrowInGame(arrow_p2) )
	for gameArrow in gameArrowList:
		gameArrow.set_grid_position( play_map.detect_grid(gameArrow.arrow.position) )

	# register key done event
	key_control = { res.control_p1['right']:lambda :game_map_turn_correct(arrow_p1, play_map, (1,0)),
					res.control_p1['left']:	lambda :game_map_turn_correct(arrow_p1, play_map, (-1,0)),
					res.control_p1['up']:	lambda :game_map_turn_correct(arrow_p1, play_map, (0,-1)),
					res.control_p1['down']:	lambda :game_map_turn_correct(arrow_p1, play_map, (0,1)),
					res.control_p1['kit']:	lambda :arrow_p1.kit_invoke(),
					res.control_p2['right']:lambda :game_map_turn_correct(arrow_p2, play_map, (1,0)),
					res.control_p2['left']:	lambda :game_map_turn_correct(arrow_p2, play_map, (-1,0)),
					res.control_p2['up']:	lambda :game_map_turn_correct(arrow_p2, play_map, (0,-1)),
					res.control_p2['down']:	lambda :game_map_turn_correct(arrow_p2, play_map, (0,1)),
					res.control_p2['kit']:	lambda :arrow_p2.kit_invoke()
					}
					
	game_over = False
	while not game_over:
		# handle event
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				return False

			if event.type == pygame.KEYDOWN:
				for key in key_control:
					if key == event.key:
						key_control[key]()
			# print(event)

		# raise game event
		if (game_arrow_encounter(arrow_p1, arrow_p2) == res.game_brokeback):
			return True
		game_arrow_map_event( gameArrowList, play_map )

		# progress game
		play_map.kit_progress()

		arrow_p1.progress()
		game_map_bump_correct( arrow_p1, play_map )

		arrow_p2.progress()
		game_map_bump_correct( arrow_p2, play_map )

		# render
		gameDisplay.fill(res.color_background)
		play_map.draw( gameDisplay )
		panel_p1.draw( gameDisplay )
		panel_p2.draw( gameDisplay )
		arrow_p1.draw( gameDisplay )
		arrow_p2.draw( gameDisplay )
		pygame.display.update()

		res.clock.tick( res.tick_game )
开发者ID:nyphoon,项目名称:BreakBack,代码行数:87,代码来源:breakback.py


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