Page 1 of 1

Animation easing?

Posted: Mon Nov 14, 2022 5:37 pm
by idoblenderstuffs
just making a basic breakout type game and this is the code i have for it atm:

function love.load()

px = 500

end

function love.update(dt)

-- paddle movement
px = love.mouse.getX()

end

function love.draw()

-- draw upper left text
love.graphics.setColor(1, 1, 1)
love.graphics.print("by idoblenderstuffs", 0, 0)
love.graphics.print(tostring(love.timer.getFPS( )),0,20)

-- draw paddle
love.graphics.line(px+100, 500, px- 100, 500)

end


in other engines, ive been able to smoothly move the paddle by doing something like

px = px - (distance to mouse/10)

but in love, this does it WAY too fast so its basically instant.
i tried using bigger values like 100, and it almost fixes it, but for some reason moving left is a lot faster than moving right?? it makes it feel extremely jank to move the paddle about like that.

how would i make the paddle smoothly move towards the mouse X?

Re: Animation easing?

Posted: Mon Nov 14, 2022 7:12 pm
by darkfrei

Code: Select all

--update
px = px - dt*(distance_to_mouse/10)
Where dt is about 1/60 seconds.

Re: Animation easing?

Posted: Thu Nov 17, 2022 1:16 pm
by wallacesmiller
This may be a really difficult question, I am very curious about the answers that will be given.