Code: Select all
---------------------------
function love.load()
love.window.setTitle("Physics Toy")
objects = {}
love.physics.setMeter(64)
world = love.physics.newWorld(0, 85, true)
end
---------------------------
function love.update(dt)
end
---------------------------
function love.draw()
for i, object in ipairs(objects) do
love.graphics.polygon("fill", object.body:getWorldPoints(object.shape:getPoints()))
end
end
---------------------------
function love.mousepressed(x, y, button)
if button=="l" then
local width = 100
local height = 175
local newobject = {}
newobject.body = love.physics.newBody(world, x, y, "dynamic")
newobject.shape = love.physics.newRectangleShape(width, height)
newobject.fixture = love.physics.newFixture(newobject.body, newobject.shape, 5)
table.insert(objects, newobject)
end
end
Wait. world:update(dt).