本文整理汇总了Python中vector.Vector.from_angle方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.from_angle方法的具体用法?Python Vector.from_angle怎么用?Python Vector.from_angle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector.Vector
的用法示例。
在下文中一共展示了Vector.from_angle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tick
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import from_angle [as 别名]
def tick(self):
if self.health > 75 and self.health_state != HEALTH_OK:
self.injured_sound.stop()
self.injured_sound = None
self.health_state = HEALTH_OK
if self.health < 75 and self.health > 50 and self.health_state != HEALTH_BAD:
if self.injured_sound:
self.injured_sound.stop()
self.injured_sound = self.play_sound('Heartbeat Slow.ogg', looping=True)
self.health_state = HEALTH_BAD
elif self.health < 50 and self.health_state != HEALTH_TERRIBLE:
if self.injured_sound:
self.injured_sound.stop()
self.injured_sound = self.play_sound('Heartbeat Fast.ogg', looping=True)
self.health_state = HEALTH_TERRIBLE
elif self.health <= 0:
if self.injured_sound:
self.injured_sound.stop()
self.injured_sound = None
self.radar.tick()
self.sweeping_radar.tick()
self.set_sound_position()
if self.attacking:
self.fire_weapon()
if self.turning == 'left':
self.facing -= self.turn_rate
elif self.turning == 'right':
self.facing += self.turn_rate
self .facing %= 360
speed = self.speed
if self.running:
speed *= self.running_multiplier
slowdown_multiplier = math_utils.inverse_percentage(speed, 100)
if self.velocity.magnitude() >= self.FOOTSTEP_SPEED:
self.only_play_every(self.FOOTSTEP_DELAY* slowdown_multiplier, self.get_footstep_sound())
else:
self.velocity = (0, 0)
if self.walking_toward:
if distance(self.walking_toward, self.position) > self.approach_distance:
self.moving = 'forward'
else:
self.moving = False
self.walking_toward = None
if self.moving:
facing = self.facing
if self.moving == 'forward':
facing = facing
elif self.moving == 'backward':
facing = (facing - 180) % 360
if self.moving == 'right':
facing = facing + 90 % 360
elif self.moving == 'left':
facing = facing - 90 % 360
self.velocity = Vector.from_angle(facing) * math_utils.percentage(self.footstep_multiplier, speed)
else:
self.body.linearVelocity = (0, 0)
示例2: ray_cast
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import from_angle [as 别名]
def ray_cast(self, start, direction, length):
"""Returns the list of game objects in order of distance from the given start at the given direction up to the given length"""
unit = Vector.from_angle(direction)
end = unit * length
end = start + end
callback = self.ray_cast_callback
callback.fixtures = set()
self.world.RayCast(callback, start, end)
fixtures = sorted(callback.fixtures)
return [i[1].body for i in fixtures]
示例3: set_sound_position
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import from_angle [as 别名]
def set_sound_position(self):
position = list(self.position)
position.append(0.0)
game.sound_manager.set_listener_position(position)
orientation = list(game.sound_manager.world.orientation.value)
orientation[0], orientation[1] = Vector.from_angle(self.facing)
game.sound_manager.set_orientation(orientation)
room = game.map.find_room_containing(self.position)
t60 = 0
if room:
t60 = tiles.area_of_room(room) / 8.0
game.sound_manager.reverb.t60.cancel_automators(0.0)
game.sound_manager.reverb.t60.linear_ramp_to_value(0.3, t60)
示例4: ray_cast_to_first_item
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import from_angle [as 别名]
def ray_cast_to_first_item(self, start, direction, length):
"""Returns the first game object in order of distance from the given start at the given direction up to the given length. Also returns the precise point at which it was hit."""
unit = Vector.from_angle(direction)
end = unit * length
end = start + end
callback = self.closest_ray_cast_callback
callback.result = None
self.world.RayCast(callback, start, end)
if not callback.result:
return
frac_distance, fixture = callback.result
distance = frac_distance * length
hitpoint = unit * distance
hitpoint = hitpoint + start
return hitpoint, fixture.body