The title says everything, I'm toying with love.physics at the moment and while I can do everything I want there is one thing that I'm missing.
I have a spaceship at the centre of the screen and I get the angle from the mouse pointer:
Code: Select all
function love.load()
world = love.physics.newWorld(0, 0, true)
...
ship.body = love.physics.newBody(world, ship.x, ship.y, "dynamic")
ship.shape = love.physics.newRectangleShape(8, 8)
ship.fixture = love.physics.newFixture(ship.body, ship.shape)
...
end
function love.update(dt)
world:update(dt)
...
ship.angle = math.atan2((pointer.y - ship.y), (pointer.x - ship.x))
ship.body:setAngle(ship.angle)
...
end
function love.draw()
...
love.graphics.polygon("line", ship.body:getWorldPoints(ship.shape:getPoints()))
...
end
Thanks.