当前位置: 首页>>代码示例>>Python>>正文


Python Physics.move_object方法代码示例

本文整理汇总了Python中Physics.move_object方法的典型用法代码示例。如果您正苦于以下问题:Python Physics.move_object方法的具体用法?Python Physics.move_object怎么用?Python Physics.move_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Physics的用法示例。


在下文中一共展示了Physics.move_object方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update

# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import move_object [as 别名]
 def update(self):
     for object in Entities.ACTIVE_OBJECTS:
         #Physics.apply_gravity(object)
         #Collision checks
         for object_b in Entities.ACTIVE_OBJECTS:
             if object == object_b:
                 continue
             if Physics.colliding(object, object_b):
                 Physics.handle_circle_collision(object, object_b)
         Physics.simulate(object)
         if object.position.x+object.size < 0 or object.position.x+object.size > self.size_x:
             object.velocity.x = 0
         if object.position.y+object.size < 0 or object.position.y+object.size > self.size_y:
             object.velocity.y = 0
         Physics.move_object(object)
开发者ID:newxan,项目名称:phys_engine,代码行数:17,代码来源:CanvasGUI.py

示例2: update

# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import move_object [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)
开发者ID:newxan,项目名称:phys_engine,代码行数:23,代码来源:PygletGUI.py


注:本文中的Physics.move_object方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。