REAL Gravity

How do I make this happen, like what code would I use?
(red is the original force, green is gravity, blue is the path that the earth "follows")

(red is the original force, green is gravity, blue is the path that the earth "follows")