Planetorium

Miscellaneous Forums/Blitz Showcase/Planetorium

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Interesting indeed. The physics are quite bad, though. The speed of a sphere after a collision should be rather the mass-weighted speed of the two spheres which fusioned and not whatever it's now.

Maybe like this:
planetxs[xx3] = (planetxs[xx3] * planetg[xx3] + planetxs[yy3] * planetg[yy3]) / ( planetg[xx3] + planetg[yy3])
planetys[xx3] = (planetys[xx3] * planetg[xx3] + planetys[yy3] * planetg[yy3]) / ( planetg[xx3] + planetg[yy3])

Of course this would have to be done after calculating the new mass.
I've done something similar before and the real challenge turned out to be creating a scenario with complex systems. Even for 3 bodies (sun-earth-moon for example) this is quite difficult and it's even more with several planets and moons at once.

With your current code 3-4 somewhat larger bodies emerge but everything dissolves after a (long) while but satellites form only very rarely. With my correction there happens what would be expected: Every piece of mass accumulates in one huge sphere, which would be the star of a planetary system. An interesting idea would be to give the bodies some kind of starting impulse, maybe orthogonal to a common central point. That would be at least a little more realistic.