Using advanced 2d would be a lot harder to deal with. The reason for this is the difference between screen space and world space. world space is like when you have an object at (2.4,4,-5.2), but this point may show up on the screen as pixel (500,600), and the transformation to get there is complicated in 3d. Not so complicated in 2d, but still not easy without a familiarity with matrix equations.
I'm kind of confused: Do you want to simulate things like the moons interaction with the sun? There's a HUGE difference between a simulation and a model.
If you want to have a simulation, you need to worry about things like position vectors, velocity and acceleration vectors, and mass. If you want to create a model, then you have to worry about things like direction and rotation.
This is a basic "model":
global sun as integer
global earth as integer
global moon as integer
global sunToEarth as integer
global earthToMoon as integer
sun=1
earth=2
moon=3
position camera 0,0,300
point camera 0,0,0,0
autocam off
make object sphere sun,10
make object sphere earth, 4
make object sphere moon, 2
color object sun,rgb(255,255,0)
color object earth, rgb(0,100,0)
color object moon, rgb(200,200,200)
position object sun, 0,0,0
sunToEarth=1
earthToMoon=2
null=make vector2(sunToEarth)
null=make vector2(earthToMoon)
set vector2 sunToEarth,100,0
set vector2 earthToMoon,5,0
repositionEarthMoon()
sync on
sync rate 60
do
Rotate_Vector2(sunToEarth,1)
Rotate_Vector2(earthToMoon,7)
repositionEarthMoon()
sync
loop
end
function repositionEarthMoon()
position object earth,x vector2(sunToEarth),y vector2(sunToEarth),0
position object moon,x vector2(sunToEarth)+x vector2(earthToMoon),y vector2(sunToEarth)+y vector2(earthToMoon),0
endfunction
function Rotate_Vector2(vector2 as integer,amount as float)
x#=x vector2(vector2)
y#=y vector2(vector2)
c#=cos(amount)
s#=sin(amount)
set vector2 vector2,x#*c#-y#*s#,y#*c#+x#*s#
endfunction
that "Rotate_Vector2" function probably seems like a little bit of magic. It's a rotation matrix applied to a vector that rotates the vector by "amount" degrees. So if you have the vector (1,0) and rotate it by 90 degrees, you get (0,1). If you have (0,1) and rotate it by 90 degrees, you get (-1,0) etc.
Simulations can get as fancy as you want. There are things called n-body simulations (
I made one) that try to simulate the attraction of thousands of different masses.
Universe Sandbox uses this kind of simulation in a more realistic way.
I'll give you a hint to start working on an unoptimized version of that n-body simulation. (unoptimized because the optimization is really complicated)
FOR each mass, you have an acceleration vector, a position vector, and a velocity vector. Forget rotation because that only comes into play when you have a physics system or are working on trying to create an accurate model.
Between two objects 1 and 2, the magnitude of the acceleration acting on object 1 is calculated by newton's inverse square law of gravity. Force=G*Mass1*Mass2/distance^2. Acceleration=force/mass, so a=G*m2/d^2. The direction of this force is in the direction of P2-P1, where P1/P2 are the objects position vectors (FROM p1 TO p2). So, normalize P2-P1, multiply it by the acceleration, and then you have a single acceleration vector for object 1. Do this for every other object (between objects 1 and 3, between objects 1 and 4, etc), and then add up all of the accelerations to get the actual acceleration.
Now the rest is the easy part. Velocity=Velocity+Acceleration*timestep, and
Position=Position+Velocity*timestep.
I was planning on writing up a vector/matrix tutorial over winter break, so stay tuned. Also, check out "Vectors Don't Bite!" if you haven't.