Animation easing?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
idoblenderstuffs
Prole
Posts: 3
Joined: Sun Nov 13, 2022 7:10 pm

Animation easing?

Post 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?
User avatar
darkfrei
Party member
Posts: 1172
Joined: Sat Feb 08, 2020 11:09 pm

Re: Animation easing?

Post by darkfrei »

Code: Select all

--update
px = px - dt*(distance_to_mouse/10)
Where dt is about 1/60 seconds.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
wallacesmiller
Prole
Posts: 1
Joined: Thu Nov 17, 2022 11:59 am
Contact:

Re: Animation easing?

Post by wallacesmiller »

This may be a really difficult question, I am very curious about the answers that will be given.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 23 guests