Created
December 20, 2012 10:28
-
-
Save jlebrech/4344489 to your computer and use it in GitHub Desktop.
Radial gravity in love2d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment