Planets and Gravity
Posted: Wed Oct 30, 2013 2:37 am
Hey guys, I saw a cool gif the other day (friend posted it on FB) and decided to write a simple gravity thing that works across multiple planets.
The math is pretty basic, essentially each planetling grabs the nearest planet and has it's valued modified according to direction and gravity. Slightly different to real life, the gravitational pull gets stronger the further away you are. Pretty C++-ish, with the polymorphism and OO.
Look at the source, learn, modify, make the planetlings bounce off the planet, whatever.
It's fairly quick, on my i5 it can handle about 5000 planetlings before it starts to dip in FPS.
License: http://www.wtfpl.net/
The math is pretty basic, essentially each planetling grabs the nearest planet and has it's valued modified according to direction and gravity. Slightly different to real life, the gravitational pull gets stronger the further away you are. Pretty C++-ish, with the polymorphism and OO.
Look at the source, learn, modify, make the planetlings bounce off the planet, whatever.
It's fairly quick, on my i5 it can handle about 5000 planetlings before it starts to dip in FPS.
License: http://www.wtfpl.net/