Page 1 of 1

Linear Dampening and wobbly sprite movement

Posted: Sat Apr 16, 2016 12:29 am
by Sawbones
I have an image that I render and is moved by a Body. When I apply linear dampening on the body the image's pixels wobble just before it stops completely. Is there a way to stop that from happening?

Code: Select all

draw = function(self)
        local x, y = self.body:getPosition()
        local width, height = self.image:getDimensions()
        love.graphics.draw(self.image, x, y, self.body:getAngle(), .25, .25, width/2, height/2)
    end

Re: Linear Dampening and wobbly sprite movement

Posted: Sat Apr 16, 2016 1:35 am
by s-ol
Snap the speed/velocity to 0 if it is close enough.

Re: Linear Dampening and wobbly sprite movement

Posted: Sat Apr 16, 2016 2:24 am
by HugoBDesigner
If you have the x/y positions be a floating point number, simply round the values down, like:

love.graphics.draw(self.image, math.floor(x), math.floor(y), self.body:getAngle(), .25, .25, width/2, height/2)

But I'm not sure if that's the problem or not.