[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Orbiting bodies in pymunk



Howdy, folks.

I made a small pymunk demo in which a Pygame sprite orbits the mouse pointer. I'm trying to figure out a way to get an elliptical orbiting body. Body.impulse is the only thing that appears to behave how I want, but after many hours of experimentation there remain gross eccentricities in the orbit that I can't resolve. The ball circles around the mouse a few times, its orbit decaying, then flips around the other way; and cycles back and forth between the two orbit-like patterns. It seems there are other influences at work: pymunk physics I don't know about yet, or maybe precision errors, or perhaps I'm just doing it all wrong.

I did the poring over docs thing, digging in modules, searching for demos and articles, and came up rather empty. Certainly nothing on topic. I did find a lot of complaints, though, about the dearth of pymunk demos. :)

If you are inclined to take a look, you'll need:
05_impulse.py
game_clock.py
pymunk

Use the down arrow to slow the ball if it gets going too fast, and move the mouse a little to guide the ball into an elliptical path.

I sure would appreciate some new insight. Thanks in advance for any assistance.

Gumm