本文整理汇总了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:
示例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: