本文整理汇总了Python中Physics.handle_rectangle_collision方法的典型用法代码示例。如果您正苦于以下问题:Python Physics.handle_rectangle_collision方法的具体用法?Python Physics.handle_rectangle_collision怎么用?Python Physics.handle_rectangle_collision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Physics
的用法示例。
在下文中一共展示了Physics.handle_rectangle_collision方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import handle_rectangle_collision [as 别名]
def update():
for object in Entities.ACTIVE_OBJECTS:
for object_b in Entities.ACTIVE_OBJECTS:
if object == object_b:
continue
if Physics.colliding(object, object_b):
if isinstance(object, Entities.Line):
#line_point = Physics.get_closestpoint(object.position, object.position+object.direction_vector, object_b.position)
#Entities.spawn_ball(line_point, 2, Physics.Vec2(0, 0), Physics.Vec2(0, 0), 0, None,
# mod=(Entities.Object.TRANS | Entities.Object.FIXED))
Physics.handle_line_collision(object, object_b)
elif isinstance(object, Entities.Rectangle):
Physics.handle_rectangle_collision(object, object_b)
else:
Physics.handle_circle_collision(object, object_b)
Physics.simulate(object)
if object.position.x+object.size < 0 or object.position.x+object.size > size_x:
object.velocity.x = 0
if object.position.y+object.size < 0 or object.position.y+object.size > size_y:
object.velocity.y = 0
Physics.move_object(object)