本文整理汇总了Python中Controller.Controller.player_collision_check方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.player_collision_check方法的具体用法?Python Controller.player_collision_check怎么用?Python Controller.player_collision_check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller.Controller
的用法示例。
在下文中一共展示了Controller.player_collision_check方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: play
# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import player_collision_check [as 别名]
def play(speed):
screen = pygame.display.set_mode(size)
myfont = pygame.font.SysFont("monospace", 30)
keys = pygame.key.get_pressed()
#Pre Run
blinkflag = 0
while (not keys[pygame.K_SPACE]):
blinkflag = blinkflag + 1
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
textmain = myfont.render(
"SPACE INVADER" , 1, (0,255,0))
starttext = myfont.render(
"Press space to start" , 1, (0,255,0))
if (blinkflag < 20):
screen.blit(starttext,(200,200))
if (blinkflag > 30):
blinkflag = 0
screen.blit(textmain,(210,50))
pygame.display.flip()
clock.tick(30)
screen.fill(black)
keys = pygame.key.get_pressed()
#Main Run
playerShip = PlayerShip([320,350])
controller = Controller(14,6,screen,speed)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
keys = pygame.key.get_pressed()
playerShip.update(keys)
playerShip.maybeShoot(keys)
screen.fill(black)
if playerShip.bullet.bulletFlag > 0: screen.blit(playerShip.bullet.image,playerShip.bullet.rect)
screen.blit(playerShip.image,playerShip.rect)
controller.blit()
controller.collision(playerShip.bullet)
controller.player_collision_check(playerShip)
pygame.display.flip()
clock.tick(30)
if (controller.gameover()):
flag = 0
break
audio.gameOver()
# Post run
blinkflag = 0
while (not keys[pygame.K_SPACE]):
blinkflag = blinkflag + 1
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
textmain = myfont.render(
"SPACE INVADER" , 1, (0,255,0))
starttext = myfont.render(
"GAME OVER" , 1, (0,255,0))
if (blinkflag < 20):
screen.blit(starttext,(230,200))
if (blinkflag > 30):
blinkflag = 0
screen.blit(textmain,(210,50))
pygame.display.flip()
clock.tick(30)
screen.fill(black)
keys = pygame.key.get_pressed()
return flag