本文整理匯總了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())