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


Python Vector.from_points方法代码示例

本文整理汇总了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
开发者ID:kaytoxlll,项目名称:mechanical-failure,代码行数:10,代码来源:states.py

示例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
开发者ID:kaytoxlll,项目名称:mechanical-failure,代码行数:17,代码来源:attacks.py

示例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
开发者ID:kaytoxlll,项目名称:mechanical-failure,代码行数:21,代码来源:sprites.py


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