> The force of gravity between objects can be done with:
F=G*m1*m2/r^2
Where
m1 and m2 are the masses of the two objects and r is the distance between them.
G is a constant. It comes from
https://en.m.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation
But since we are not dealing with real world scales we can just fudge it.
You can try the following. Also to get the moon to orbit you just have to have the perpendicular velocity high enough.
Global number a=0
Global number r=0
Global number f=0
For each planet
— set a to angle(moon.x, moon.y, planet.x, planet.y)
— set r to distance(moon.x, moon.y, planet.x, planet.y)
— set f to 100 * moon.physics.mass * planet.physics.mass/r^2
— moon: physics: apply force (f*cos(a), f*sin(a))
Great explanation, I had already tried to use Newton's theory but I couldn't apply it correctly, but his explanation helped me to understand the concept and to get what I needed, thanks to everyone :D