本文整理汇总了Python中helper.Helper.objects_collide方法的典型用法代码示例。如果您正苦于以下问题:Python Helper.objects_collide方法的具体用法?Python Helper.objects_collide怎么用?Python Helper.objects_collide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helper.Helper
的用法示例。
在下文中一共展示了Helper.objects_collide方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_objects_collide1
# 需要导入模块: from helper import Helper [as 别名]
# 或者: from helper.Helper import objects_collide [as 别名]
def test_objects_collide1(self):
'''Test the objects collision detection w/ multiple scenarios.'''
pos1, r1 = (0,0), 1
pos2, r2 = (0,2), 1
self.assertFalse(Helper.objects_collide(pos1, r1, pos2, r2))
pos1, r1 = (0,0), 1
pos2, r2 = (0,1), 0
self.assertFalse(Helper.objects_collide(pos1, r1, pos2, r2))
pos1, r1 = (0,0), 1
pos2, r2 = (0,1), 1
self.assertTrue(Helper.objects_collide(pos1, r1, pos2, r2))
pos1, r1 = (0,0), 1
pos2, r2 = (2,2), 1
self.assertFalse(Helper.objects_collide(pos1, r1, pos2, r2))
示例2: __generate_coord_without_collision
# 需要导入模块: from helper import Helper [as 别名]
# 或者: from helper.Helper import objects_collide [as 别名]
def __generate_coord_without_collision(self, collision_list, collision_radius):
'''Generate a new coordinate so that it does not collide with any
of the coords from collision_list.
'''
x,y = self.__get_dimensions()
while True:
coord = (random.random()*x, random.random()*y)
# new generated coord should not conflict w/ collision list.
for (coord2, collision_radius2) in collision_list:
if Helper.objects_collide(coord, collision_radius,
coord2, collision_radius2):
break
# did not break, thus no collision w/ any of coords from list.
else:
return coord
示例3: objects_collide
# 需要导入模块: from helper import Helper [as 别名]
# 或者: from helper.Helper import objects_collide [as 别名]
def objects_collide(o1, o2):
return Helper.objects_collide(o1.coord, o1.collision_radius,
o2.coord, o2.collision_radius)
示例4: test_objects_collide2
# 需要导入模块: from helper import Helper [as 别名]
# 或者: from helper.Helper import objects_collide [as 别名]
def test_objects_collide2(self):
pos1, r1 = (0,0), 10
r2 = 15
pos2 = (0, r1 + r2 - 1)
self.assertTrue(Helper.objects_collide(pos1, r1, pos2, r2))