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


Python Ball.setName方法代码示例

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


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

示例1: main

# 需要导入模块: from Ball import Ball [as 别名]
# 或者: from Ball.Ball import setName [as 别名]
def main():
	"""This is the main function called when the program starts. It initializes
	everything it needs, then runs in a loop until exited. """

	display = Display()

	background = display.drawBackground()
	display.drawPitch(background)
	display.centreTitleOnBackground(background)

	# Prepare Game Objects
#	clock = pygame.time.Clock()
	clock = pygw.clock()
	WM = WorldModel()
	ball = Ball()
	blue1 = Agent(BLUE1_START_POS, 1, BLUE_START_ANGLE, WM)
	blue2 = Agent(BLUE2_START_POS, 2, BLUE_START_ANGLE, WM)
	red1 = Agent(RED1_START_POS, 3, RED_START_ANGLE, WM)
	red2 = Agent(RED2_START_POS, 4, RED_START_ANGLE, WM)

	ball.setName("ball")
	blue1.setName("blue1")
	blue2.setName("blue2")
	red1.setName("red1")
	red2.setName("red2")

#	ballSprite = pygame.sprite.RenderPlain(ball)
	ballSprite = pygw.renderplainsprite(ball)
	blue1Sprite = pygw.renderplainsprite(blue1)
	blue2Sprite = pygw.renderplainsprite(blue2)
	red1Sprite = pygw.renderplainsprite(red1)
	red2Sprite = pygw.renderplainsprite(red2)

	frame = 0
	going = True

	# Main game loop
	while going:
		clock.tick(FPS)

		if frame >= 30:
			frame = 0
		else:
			frame += 1

		allData = [ball, blue1, blue2, red1, red2]
		if (frame % WORLD_MODEL_UPDATE) == 0:
			WM.update_info(allData)

		#Update Sprites
		ballSprite.update()
		blue1Sprite.update()
		blue2Sprite.update()
		red1Sprite.update()
		red2Sprite.update()

		#Draw Everything
		display.drawEverything(background, ballSprite, blue1Sprite, blue2Sprite, red1Sprite, red2Sprite)
		display.updateFeaturesOnScreen(frame, ball, blue1, blue2, red1, red2)

		#Check for kicks
		ball.setPushValue(0)
		if blue1.kicking or blue2.kicking or red1.kicking or red2.kicking:
			ball.setPushValue(1)
			ball.setPushSpeed(5)
		if blue1.kicking:
			ball.setPushOrientation(blue1.angle)
		elif blue2.kicking:
			ball.setPushOrientation(blue2.angle)
		elif red1.kicking:
			ball.setPushOrientation(red1.angle)
		elif red2.kicking:
			ball.setPushOrientation(red2.angle)
#
#		ball.setPushValue(0)
#
#		if ball.speed == 0:
#			ball.setPushValue(1)
#			ball.setPushOrientation(np.random.randint(0, 360))
#			ball.setPushSpeed(5)

#		pygame.display.flip()
		pygw.updatefulldisplay()
#		for event in pygame.event.get():
		for event in pygw.getIOevent():
			if event.type == pygw.QUIT or event.type == pygw.KEYDOWN and event.key == pygw.K_ESCAPE:
				going = False
				print('User quit the game')

#	pygame.quit()
	pygw.quitgame()
	sys.exit()
开发者ID:GreatAlexander,项目名称:Games,代码行数:94,代码来源:main.py


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