Grav2D: Attraction causes LÖVE
Posted: Sun Mar 05, 2017 5:43 am
Hiya everybody! I've got something pretty cool to show you!
This library adds the normal love.physics by allowing bodies to be influenced by another body's mass, called gravity, as well as some small other things. The following is a demonstration of what Grav2D can do in 38 lines of code:
(This example is attached with the library as an example)
Currently, Grav2D has 5 major functions:
>Returns a new Grav2D Object for you to play around with
>Applies the appropriate gravitational forces to the body of the object
>Returns a debug table with the average force, angle (in degrees), and distance, as well as a world body count
>Draws the Shape of the Object in the World so you don't have to.
--AND--
>Converts polar coordinates (distance, angle in radians) to Cartesian (x, y) and vice versa. Good for setting forces and impulses as vectors.
TODO:welcomed needed, this is a W.I.P.
This library adds the normal love.physics by allowing bodies to be influenced by another body's mass, called gravity, as well as some small other things. The following is a demonstration of what Grav2D can do in 38 lines of code:
(This example is attached with the library as an example)
Currently, Grav2D has 5 major functions:
Code: Select all
Grav2D.new(body,shape,mass)
Code: Select all
[Grav2D Object]:applyGrav()
>Returns a debug table with the average force, angle (in degrees), and distance, as well as a world body count
Code: Select all
[Grav2D Object]:draw(mode)
Code: Select all
Grav2D.toCartesian(r,θ)
Code: Select all
Grav2D.toPolar(x,y)
TODO:
- Make Blacklisting/Whitelisting body arguments to :applyGrav()
- Optional make :applyGrav only return debugTable
- Allow bodies to be attracted to arbitrary points in space or axes
- Give support to non-polygon or circular shapes
- Give option for polygons to attract object based on which side the object is closest to
- Anything you guys suggest that sounds neato