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


Python Player.hit方法代码示例

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


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

示例1: str

# 需要导入模块: import Player [as 别名]
# 或者: from Player import hit [as 别名]
        targetIdx = bm.rect.collidelist(deadList)
        if targetIdx > -1:
            targetObj = deadList[targetIdx]
            print "Popal v "+ targetObj.name + " HP left: "+ str(targetObj.getHP())
            targetObj.hit(bm.damage)
            beamsList.remove(bm)
            sndAlien1.play()
            #d_alnRect.center = aln1Rect.center
            # if not targetObj.isAlive():
            #     deadList.append(targetObj)
            #     atackersList.remove(targetObj)
            continue

        ### hit player
        if bm.rect.colliderect(plr.rect):
            plr.hit(bm.damage)
            beamsList.remove(bm)
            sndAlien1.play()
            continue

    ### process colisions
    for obj in allObjList:
        allObjList.remove(obj)
        targetIdx = obj.rect.collidelist(allObjList)
        if targetIdx > -1:
            obj.moveBack()
            allObjList[targetIdx].moveBack()
        allObjList.append(obj)

    ### player lost
    if plr.getHP() < 1:
开发者ID:mgx259,项目名称:PyGameTest1,代码行数:33,代码来源:game1.py

示例2:

# 需要导入模块: import Player [as 别名]
# 或者: from Player import hit [as 别名]
         shots_t.remove(x)
         if health >= 0:
             healthBar.image = pygame.image.load("health%d.png"%(health))
         if health < 0:
             health = 0
             playing = False
             lose = True
         col = True
         break
     
 # collide with enemy
 for enemy in enemy_list:
     if player.hit == False:
         if player.rect.colliderect(enemy):
             i_timer = pygame.time.get_ticks()
             player.hit = True
             health -= 1
             if health >= 0:
                 healthBar.image = pygame.image.load("health%d.png"%(health))
             if health < 0:
                 health = 0
                 playing = False 
                 lose = True
 if player.hit == False:
     if tigerwoods.rect.colliderect(player.rect):
         i_timer = pygame.time.get_ticks()
         player.hit = True
         health -=3
         if health >= 0:
             healthBar.image = pygame.image.load("health%d.png"%(health))
         if health < 0:
开发者ID:LinkCable,项目名称:Spooned,代码行数:33,代码来源:main.py


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