[pygame] Orbiting bodies in pymunk

2010-10-01 Thread B W
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


Re: [pygame] Quit pygame

2010-10-01 Thread Lenard Lindstrom

On 30/09/10 04:23 PM, Kris Schnee wrote:

On 2010.9.30 12:01 PM, Massimo Di Stefano wrote:

I tried the following code in a standard python shell :


from pygame.locals import *
import pygame
pygame.init()

Leopard libedit detected.
(6, 0)

for event in pygame.event.get():

... if event.type == QUIT:
... running = False
...

pygame.event.pump()
pygame.quit()


Different note: isn't pygame.event.pump redundant here, since you're 
already clearing the latest events by calling pygame.event.get()?


Probably. I just suggested pygame.event.pump as an alternative to an 
event loop. But pygame.init() does not open a window, so no event loop 
should be needed.


Lenard Lindstrom