lua - Love2d and radial gravity -
i've found interesting article on adding radial gravity box2d.
http://www.vellios.com/2010/06/06/box2d-and-radial-gravity-code/
to port lua though need calculate distance squared , normalize distance.
love2d doesn't seem have functions extract appropriate vector, shame.
unless math lacking , me out.
i can alway switch box2d love2d seemed neat solution.
i've found how using hump library.
like this.
ship = bodies[1] shipvec = vector(ship:getx(),ship:gety()) planet = bodies[2] planetvec = vector(planet:getx(),planet:gety()) distance = planetvec – shipvec force = 250 / distance:len2() normforce = force*distance bodies[1]:applyimpulse(normforce.x, normforce.y,ship:getx(),ship:gety())
Comments
Post a Comment