Re: rotation question
Posted: Sun Dec 17, 2017 5:49 pm
Code: Select all
function love.load()
love.mouse.setVisible(false)
lAngle = -90
dAngle = 0
end
function love.draw()
love.graphics.setColor(255, 255, 255, 255)
love.graphics.ellipse("fill", mX, mY, 4, 4)
love.graphics.ellipse("fill", 400, 200, 10, 10)
love.graphics.setColor(255, 0, 0, 255)
lX = 400 + 100 * math.cos(math.rad(lAngle))
lY = 200 + 100 * math.sin(math.rad(lAngle))
love.graphics.line(400, 200, lX, lY)
at2 = math.deg(math.atan2(mY-200, mX-400))
love.graphics.print(at2 , mX, mY)
if lAngle < at2 and mY < 200 then
dAngle = 0.5
else
dAngle = -0.5
end
lAngle = lAngle + dAngle
end
function love.update(dt)
mX, mY = love.mouse.getPosition()
end
But the problem I still there :\mr_happy wrote: ↑Sun Dec 17, 2017 5:54 pm Here you go, quick and dirty:
Code: Select all
function love.load() love.mouse.setVisible(false) lAngle = -90 dAngle = 0 end function love.draw() love.graphics.setColor(255, 255, 255, 255) love.graphics.ellipse("fill", mX, mY, 4, 4) love.graphics.ellipse("fill", 400, 200, 10, 10) love.graphics.setColor(255, 0, 0, 255) lX = 400 + 100 * math.cos(math.rad(lAngle)) lY = 200 + 100 * math.sin(math.rad(lAngle)) love.graphics.line(400, 200, lX, lY) at2 = math.deg(math.atan2(mY-200, mX-400)) love.graphics.print(at2 , mX, mY) if lAngle < at2 and mY < 200 then dAngle = 0.5 else dAngle = -0.5 end lAngle = lAngle + dAngle end function love.update(dt) mX, mY = love.mouse.getPosition() end
Code: Select all
function love.load()
love.mouse.setVisible(false)
lAngle = 90
dAngle = 0
end
function love.draw()
love.graphics.setColor(255, 255, 255, 255)
love.graphics.ellipse("fill", mX, mY, 4, 4)
love.graphics.ellipse("fill", 400, 200, 10, 10)
love.graphics.setColor(255, 0, 0, 255)
lX = 400 + 100 * math.cos(math.rad(lAngle))
lY = 200 + 100 * math.sin(math.rad(lAngle))
love.graphics.line(400, 200, lX, lY)
at2 = math.deg(math.atan2(mY-200, mX-400))
diff = lAngle -at2
if diff > 360 then diff = diff - 360 end
love.graphics.print(diff , mX, mY)
if diff > 180 or diff < 0 then
dAngle = 0.5
else
dAngle = -0.5
end
lAngle = lAngle + dAngle
end
function love.update(dt)
mX, mY = love.mouse.getPosition()
end
function love.keypressed(key)
if key == 'escape' then love.event.quit() end
end
Code: Select all
function love.load()
love.mouse.setVisible(false)
lAngle = 90
dAngle = 0
end
function love.draw()
love.graphics.setColor(255, 255, 255, 255)
love.graphics.ellipse("fill", mX, mY, 4, 4)
love.graphics.ellipse("fill", 400, 200, 10, 10)
love.graphics.setColor(255, 0, 0, 255)
lX = 400 + 100 * math.cos(math.rad(lAngle))
lY = 200 + 100 * math.sin(math.rad(lAngle))
love.graphics.line(400, 200, lX, lY)
at2 = math.deg(math.atan2(mY-200, mX-400))
diff = lAngle -at2
if diff > 360 then diff = diff - 360 end
if diff < -180 then diff = diff + 360 end
love.graphics.print(diff , mX, mY)
if diff >= 180 or diff < 0 then
dAngle = 0.5
else
dAngle = -0.5
end
lAngle = lAngle + dAngle
end
function love.update(dt)
mX, mY = love.mouse.getPosition()
end
function love.keypressed(key)
if key == 'escape' then love.event.quit() end
end