本文整理汇总了Python中entities.Entity.moveTo方法的典型用法代码示例。如果您正苦于以下问题:Python Entity.moveTo方法的具体用法?Python Entity.moveTo怎么用?Python Entity.moveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entities.Entity
的用法示例。
在下文中一共展示了Entity.moveTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import moveTo [as 别名]
def __init__(self, map, position):
print "New player"
Entity.__init__(self)
self._lock = None
self._phys = Verlet(position)
self._phys.setDamping((0.02, 0.02, 0.0002))
self._phys.setGravity((0, 0, -0.00006))
self._on_floor = False
self._speed = 0
self._map = map
self._heading = 0
self.reset()
r = self._radius = 0.1
self.setBounds(((-r, -r, -r), (r, r, r))) # entity stuff
Entity.moveTo(self, position) # keep the entity updated
self._scaling = T.scale_matrix(self._radius)
self._last_pos = N.array((0, 0, 0), dtype="f")
self._graphics = R.loadObject("sphere.obj", "diffuse")
示例2: update
# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import moveTo [as 别名]
def update(self, time):
if self._destroyed:
return False
if self._t0 is None:
self._t0 = time
if self._follow is not None and not self._follow.closing() :
d = self._follow._pos - self._pos
T.unit_vector(d,d)
self._dir = self._dir * (1-self._thrust) + d * self._thrust
if time - self._t0 > 3000 or self._follow._destroyed:
print "Not following anymore"
self._follow = None
Entity.moveTo(self, self._pos + self._dir * self._speed) # also updates _pos
else:
# too simple to use Verlet
Entity.moveTo(self, self._pos + self._dir * self._speed) # also updates _pos
self._dir += self._gravity
self._xform = mmult(self._pos_m,self._scaling_m, T.quaternion_matrix(self._rotation))
self._rotation = T.quaternion_multiply(self._d_rotation, self._rotation)
# hit the floor
if self._map(self._pos[0], self._pos[1], False) > self._pos[2]:
self.explode()
return False # tell the scene the missile is toast
return True
示例3: update
# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import moveTo [as 别名]
def update(self, time):
self._lock = None
# ----- here be dragons
ph = self._phys
ph._impuse = ph._gravity
ph.update()
# test for collision with map
z, normal = self._map(ph._position[0], ph._position[1])
h = (z + self._radius) - ph._position[2]
T.unit_vector(normal, out=normal)
self._on_floor = h > 0
if self._on_floor and ph._position[2] < ph._last_position[2]: # collision
ph._impulse += h * normal * 0.00001 # * normal[2]
ph._position[2] += h
ph._last_position[2] += h
new_pos = ph._position
# -----
self._dir = new_pos - self._pos
self._speed = T.vector_norm(self._dir)
self._last_pos[:] = new_pos
Entity.moveTo(self, new_pos) # updates self._pos too
self._normal = normal
self._axis = N.cross(self._dir, normal)
self.roll(self._axis)
示例4: moveTo
# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import moveTo [as 别名]
def moveTo(self, pos):
dp = pos - self._pos
Entity.moveTo(pos)
self._phys.displace(dp)