Okay, so I've been working on a program where you add planets to a solar system and try to get them to orbit a sun. What I need, and have been having great troubles with figuring out, is a 'guide line' to show you where your planet is going to be going before you actually click to place it in the level. I'm looking for something kind of like the line on angry birds just before you release your finger that shows you where the bird is going to go. I don't need the actual code for this. just the general idea of how that works would be awesome. any help with this is much appreciated. thank you

I guess the orbit of your planet starts with a parabola, to become an ellipse, just calculate the tangent line on the point where your planet actually is.
Or if you know the tangent, calculate a parabola between the actual point and the point where the planet will come in orbit.
Don't know your exact intentions. Hope it helps.

My problem is calculating what the line should be. Drawing the line is easy.

The way everything works right now is that you click and drag to add position and velocity to a new 'Planet' object and add it to a list of all the 'planets'. there is then an update method in each object that is called that runs through a bunch of math and changes the positions and velocities of the objects. then i just call a render method in each object that sends the sprite and coords of the object to a screen class and draws the object to the screen.

what i was thinking i had to do to get the line was make a new object for the line and have an update method in that. then just copy the update method from the 'Planet' objects to it and modify it slightly so it spits out a bunch of coords to send to the screen class to draw the position and shape of the curve.

does that make any sense?

This article has been dead for over six months. Start a new discussion instead.