I assume you're doing something like this for inertia:
x#=x#+vx#
y#=y#+vy#
x,y is ship positions, vx,vy is ship speed in x and y directions.
Any force on the ship doesn't directly change it position, it changes its speed. For gravity, the force falls off as 1/(r^2) , where r is the distance between your ship and the planet centre.
r_squared=(x-planet\x)^2 + (y-planet\y)^2
force#=constant/r_squared
The force is pointing in a direction from the ship towards the centre of the planet. The force in x and y directions is:
fx#=force*(planet\x-x)/r
fy#=force*(planet\y-y)/r
(r=sqrt(r_squared))
I THINK that lot's right - you'll have to try it - may have some wrong. You'll get problems if r goes to zero - so keep your ship away from the centre of the planet or put a case in that skips the force if r is zero or v small. You could try a force of 1/r oor 1/sqrt(r) - not technically correct but whatever gives the game the best feel. You will have to play with the size of 'constant' aswell.
x#=x#+vx#
y#=y#+vy#
x,y is ship positions, vx,vy is ship speed in x and y directions.
Any force on the ship doesn't directly change it position, it changes its speed. For gravity, the force falls off as 1/(r^2) , where r is the distance between your ship and the planet centre.
r_squared=(x-planet\x)^2 + (y-planet\y)^2
force#=constant/r_squared
The force is pointing in a direction from the ship towards the centre of the planet. The force in x and y directions is:
fx#=force*(planet\x-x)/r
fy#=force*(planet\y-y)/r
(r=sqrt(r_squared))
I THINK that lot's right - you'll have to try it - may have some wrong. You'll get problems if r goes to zero - so keep your ship away from the centre of the planet or put a case in that skips the force if r is zero or v small. You could try a force of 1/r oor 1/sqrt(r) - not technically correct but whatever gives the game the best feel. You will have to play with the size of 'constant' aswell.