[HELP]Rotating circles around the middle and not corner
Posted: Fri Jan 12, 2018 2:41 pm
Hello everyone!
I'm currently making a "solarsystem" for fun and to get a better understanding of how Löve2D works.
I've just hit a roadblock in where I try to make my planets rotate around a point that's supposed to be in the middle of the screen and for some reason the rotation is set in the upper left corner of the window.
Is there anyway for my to change the rotations "origin point" to the middle of the screen.
I'm also open for suggestions on how to make the code more efficient
Thanks!
I'm currently making a "solarsystem" for fun and to get a better understanding of how Löve2D works.
I've just hit a roadblock in where I try to make my planets rotate around a point that's supposed to be in the middle of the screen and for some reason the rotation is set in the upper left corner of the window.
Is there anyway for my to change the rotations "origin point" to the middle of the screen.
I'm also open for suggestions on how to make the code more efficient
Thanks!
Code: Select all
local angle = 0
function love.load()
circle = love.graphics.newImage("circle.png")
circleW = circle:getWidth()
circleH = circle:getHeight()
planetX = love.graphics.getWidth()/2
planetY = love.graphics.getHeight()/2
sunX = love.graphics.getWidth()/2
sunY = love.graphics.getHeight()/2
end
function love.update(dt)
angle = angle - dt * math.pi/2
end
function love.draw()
-- Sun
love.graphics.setColor(255, 204, 0)
love.graphics.draw(circle, sunX, sunY, 0, 1, 1, circleW, circleH)
love.graphics.rotate(angle)
-- Mercury
love.graphics.draw(circle, planetX - 100, planetY, 0, .25, .25, circleW, circleH)
end