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


Python Ship.die方法代码示例

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


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

示例1: main

# 需要导入模块: import Ship [as 别名]
# 或者: from Ship import die [as 别名]

#.........这里部分代码省略.........

			#Draws the stars
			for i in range(0,len(stars)):
				#pygame.draw.line(screen, (255,255,255), (stars[i][0], stars[i][1]), (stars[i][0], stars[i][1]))
				pygame.draw.circle(screen,(255,255,255),stars[i],0)

			for sprite in allsprites:#Draws and updates all game sprites
				sprite.update()
				sprite.hb_follow()

				if SHOW_HITBOXES == True:
					pygame.draw.line(screen, (255,0,0), (sprite.hitbox.x, sprite.hitbox.y), (sprite.hitbox.x+sprite.hitbox.width, sprite.hitbox.y))
					pygame.draw.line(screen, (255,0,0), (sprite.hitbox.x+sprite.hitbox.width, sprite.hitbox.y), (sprite.hitbox.x+sprite.hitbox.width, sprite.hitbox.y+sprite.hitbox.height))
					pygame.draw.line(screen, (255,0,0), (sprite.hitbox.x+sprite.hitbox.width, sprite.hitbox.y+sprite.hitbox.height), (sprite.hitbox.x, sprite.hitbox.y+sprite.hitbox.height))
					pygame.draw.line(screen, (255,0,0), (sprite.hitbox.x, sprite.hitbox.y+sprite.hitbox.height), (sprite.hitbox.x, sprite.hitbox.y))


				if sprite.generictype == "Coin":#coins
					if sprite.y < -20 or sprite.y > 720 or sprite.x < -20 or sprite.x > 1020:#This conditional removes off-screen coins
						allsprites.remove(sprite)
						del(sprite)

				elif sprite.generictype == "MyWeapon":#weapons
					if sprite.y < -20 or sprite.y > 1000:#This conditional checks if a laser is off of the screen and deletes it
						allsprites.remove(sprite)
						del(sprite)

				elif sprite.generictype == "EnemyWeapon":#Draws enemy weapons
					if pygame.Rect.colliderect(sprite.hitbox, my_ship.hitbox) == 1:
						allsprites.remove(sprite)
						my_ship.hp -= sprite.damage
						damage0.play()
						if my_ship.hp < 0:
							my_ship.die()
							highscore(hs_table, score)
					if sprite.y > 700:
						allsprites.remove(sprite)

				elif sprite.generictype == "PowerUp":
					if sprite.y < -20 or sprite.y > 720 or sprite.x < -20 or sprite.x > 1020:
						allsprites.remove(sprite)
						del(sprite)

					if pygame.Rect.colliderect(sprite.hitbox, my_ship.hitbox) == 1:
						power0.play()
						my_ship.xpowerup = sprite.name
						my_ship.fire_delay = sprite.pow_speed
						my_ship.coolantbonus = sprite.coolant
						my_ship.powerleft = sprite.duration
						my_ship.powermax = sprite.duration
						allsprites.remove(sprite)

				elif sprite.generictype == "Upgrade":
					if sprite.y < -20 or sprite.y > 720 or sprite.x < -20 or sprite.x > 1020:
						allsprites.remove(sprite)
						del(sprite)

					if pygame.Rect.colliderect(sprite.hitbox, my_ship.hitbox) == 1:
						power0.play()
						if sprite.spectype == "damage0":
							my_ship.upgrades[0]=sprite.name
						elif sprite.spectype == "backfire":
							my_ship.upgrades[1]=sprite.name
						allsprites.remove(sprite)

				elif sprite.generictype == "Enemy":
开发者ID:Calendis,项目名称:S3,代码行数:70,代码来源:void.py


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