Code: Select all
function love.load()
love.physics.setMeter(64)
world = love.physics.newWorld(0, 9.81*64, true)
objects = {}
objects.ground = {}
objects.ground.body = love.physics.newBody(world, 0, 400, "static")
objects.ground.shape = love.physics.newRectangleShape(500, 1)
objects.ground.fixture = love.physics.newFixture(objects.ground.body, objects.ground.shape);
objects.ball = {}
objects.ball.body = love.physics.newBody(world, 50, 50, "dynamic")
objects.ball.shape = love.physics.newCircleShape(20)
objects.ball.fixture = love.physics.newFixture(objects.ball.body, objects.ball.shape, 3)
objects.ball.fixture:setRestitution(0.8)
objects.block1 = {}
objects.block1.body = love.physics.newBody(world, 500, 1, "static")
objects.block1.shape = love.physics.newRectangleShape(0, 0, 1, 1)
objects.block1.fixture = love.physics.newFixture(objects.block1.body, objects.block1.shape, 2)
love.graphics.setBackgroundColor(255, 255, 255)
love.window.setMode(500, 400)
end
function love.update(dt)
world:update(dt)
if love.mouse.isDown("l") then
end
function love.draw()
love.graphics.setColor(193, 47, 14)
love.graphics.circle("fill", objects.ball.body:getX(), objects.ball.body:getY(), objects.ball.shape:getRadius())
love.graphics.setColor(50, 50, 50)
love.graphics.polygon("fill", objects.block1.body:getWorldPoints(objects.block1.shape:getPoints()))
end