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


Python Controller.player_collision_check方法代码示例

本文整理汇总了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
开发者ID:Anshumankumar,项目名称:space_invaders_2015,代码行数:69,代码来源:main.py


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