Linear Dampening and wobbly sprite movement

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
Sawbones
Prole
Posts: 2
Joined: Fri Apr 15, 2016 10:52 pm

Linear Dampening and wobbly sprite movement

Post 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
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Linear Dampening and wobbly sprite movement

Post by s-ol »

Snap the speed/velocity to 0 if it is close enough.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

Re: Linear Dampening and wobbly sprite movement

Post 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.
@HugoBDesigner - Twitter
HugoBDesigner - Blog
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests