本文整理汇总了Python中navigation.Navigation.get_actual_speed方法的典型用法代码示例。如果您正苦于以下问题:Python Navigation.get_actual_speed方法的具体用法?Python Navigation.get_actual_speed怎么用?Python Navigation.get_actual_speed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类navigation.Navigation
的用法示例。
在下文中一共展示了Navigation.get_actual_speed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Torpedo
# 需要导入模块: from navigation import Navigation [as 别名]
# 或者: from navigation.Navigation import get_actual_speed [as 别名]
class Torpedo(MovableSeaObject):
def __init__(self, sea):
MovableSeaObject.__init__(self, sea, max_speed=42, max_turn_rate_hour=math.radians(720)*60)
self.navigation = Navigation(self)
self.deep = 100
self.armed = False
self.fuel = 100 * 40 # seconds at 40 knots
def launch(self, pos, speed = 40):
self.navigation.set_destination(pos)
self.speed = speed
def get_deep(self):
return self.deep
def get_fuel_consumption(self, time_elapsed):
# 1 fuel unit per second per knot
return 1.0 * time_elapsed * self.navigation.get_actual_speed()
def turn(self, time_elapsed):
MovableSeaObject.turn(self, time_elapsed)
self.fuel -= self.get_fuel_consumption(time_elapsed)
if self.fuel <= 0:
self.navigation.MAX_SPEED = 0
self.MAX_SPEED = 0
def explode(self):
self.sea.report_explosion(self.get_pos())