views:

50

answers:

1

This is pygame 1.9 on python 2.6..

Here is a screenshot of what is currently being drawn in my "game" to give some context. Here is the code.

It's supposed to be the moon orbiting around the earth (I'm not trying to make a real simulation or anything, I'm just using the setting to play around and learn pygame). It's 2 circles, and the moons elliptical orbit around the earth. My end game is to have the moon follow it's orbit around the earth, but I want to later use keyboard controls to adjust the shape of the moons orbit.

I really just need help with figuring out how to make the moon follow the path, I could probably figure the rest out.

+1  A: 

Well here is how you generate points along an ellipse:

for degree in range(360):
    x = cos(degree * 2 * pi / 360) * radius * xToYratio
    y = sin(degree * 2 * pi / 360) * radius

(x,y) will follow an ellipse centered at (0,0), with the y radius being radius and the x radius being xToYratio. In your case, you probably want degree to be related to time passing somehow.

Claudiu
I think is generally what I need to do, but part of my problem is I'm not sure how to find the radius of the ellipse since i define the ellipse by using the Rect class (see my code).
Danny