Module
love.physics
The physics module is capable of deteting collisions between objects, and simulate a realistic responses.

The module is currently based on Box2D. The original naming scheme is kept, and most of the functionality avaliable in Box2D is avaliable in LÖVE, so you can also take a look at the Box2D User Manual for detailed documentation.

Some limitations to keep in mind:
  • Only convex shapes are supported.
  • The max vertex count for on a single polygon is 8.
  • There are 16 shape categories.
Types
World Contains all Bodies and joints.
Contact Represents a contact point between two shapes.
Body A Body is a physical entity with position and orientation.
CircleShape A simple circle which can be attatched to Bodies.
PolygonShape Convex polygon which can be attatched to Bodies.
DistanceJoint Maintains a certain distance between Bodies.
RevoluteJoint Allow two Bodies to revolve around a shared point.
PrismaticJoint Restricts relative motion between Bodies to one shared axis.
MouseJoint For controlling objects with the mouse.
Examples
Example 100: Filler
angle = 0

function load()
    image = love.graphics.newImage("images/love-ball.png", love.image_optimize)
end

function update(dt)
    angle = angle + dt
    x, y = 400 + math.cos(angle)*100, 300 + math.sin(angle)*100
end

function draw()
    local rot = angle*180/math.pi
    local sx = math.cos(angle)*3
    local sy = math.sin(angle)*2
    love.graphics.draw(image, x, y, rot, sx, sy)
end
Copyright © 2006-2008 LÖVE Development Team.