Exemple #1
0
 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)
Exemple #2
0
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)