本文整理汇总了Python中vector.Vector.from_points方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.from_points方法的具体用法?Python Vector.from_points怎么用?Python Vector.from_points使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector.Vector
的用法示例。
在下文中一共展示了Vector.from_points方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doActions
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import from_points [as 别名]
def doActions(self):
"""Move toward the hero.
Raise AIAlert if the move fails."""
dest = self.target.rect.center
vect = Vector.from_points(self.npc.rect.center, dest).normalize()
if self.npc.move(vect) <> "success":
raise AIError(self.npc.name+" seeking move failed.")
return
示例2: __init__
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import from_points [as 别名]
def __init__(self, npc, reference, dest):
BasicAttack.__init__(self)
#global images
self.npc = npc
self.name = npc.name
self.damage = npc.dex
self.vector = Vector.from_points(npc.rect.center, dest).normalize()
self.speed = 15
self.image = globalvars.images["ammo" + reference]
self.rect = self.image.get_rect()
x = 0
y = 0
# start the shot in the center of the tile in front of the npc
startrect = npc.space_ahead()
self.rect.center = startrect.center
示例3: hit
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import from_points [as 别名]
def hit(self, attack, frompoint, knockback=5):
"""Just got attacked.
Returns True if the attack hit, else False
"""
if type(self) == NPC:
return False
if self.flinchtimer > 0:
return False
self.hp -= attack.damage
if self.hp < 1:
self.die()
sfxPlay(self.sfxdead)
else:
self.flinchtimer = 1
self.attacked = True
sfxPlay(self.sfxhurt)
vect = Vector.from_points(frompoint, self.rect.center)
self.knockback(vect, attack, knockback)
return True