本文整理匯總了Python中horizons.util.Circle.contains方法的典型用法代碼示例。如果您正苦於以下問題:Python Circle.contains方法的具體用法?Python Circle.contains怎麽用?Python Circle.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類horizons.util.Circle
的用法示例。
在下文中一共展示了Circle.contains方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_ground_units
# 需要導入模塊: from horizons.util import Circle [as 別名]
# 或者: from horizons.util.Circle import contains [as 別名]
def get_ground_units(self, position=None, radius=None):
"""@see get_ships"""
if position is not None and radius is not None:
circle = Circle(position, radius)
return [unit for unit in self.ground_units if circle.contains(unit.position)]
else:
return self.ground_units
示例2: get_buildings
# 需要導入模塊: from horizons.util import Circle [as 別名]
# 或者: from horizons.util.Circle import contains [as 別名]
def get_buildings(self, position=None, radius=None):
"""@see get_ships"""
buildings = []
if position is not None and radius is not None:
circle = Circle(position, radius)
for island in self.islands:
for building in island.buildings:
if circle.contains(building.position.center()):
buildings.append(building)
return buildings
else:
return [b for b in island.buildings for island in self.islands]
示例3: get_ships
# 需要導入模塊: from horizons.util import Circle [as 別名]
# 或者: from horizons.util.Circle import contains [as 別名]
def get_ships(self, position=None, radius=None):
"""Returns all ships on the map, optionally only those in range
around the specified position.
@param position: Point or Rect instance.
@param radius: int radius to use.
@return: List of ships.
"""
if position is not None and radius is not None:
circle = Circle(position, radius)
return [ship for ship in self.ships if circle.contains(ship.position)]
else:
return self.ships