Cool--yeah I'd recommend looking into events and event processing.

As I understand it, when things happen (mouse moves, press button, etc.),
they're added to the event *queue*.  If you don't retrieve values from the
event queue, then you'll only be dealing with the first value in the list.

I find the following code useful for event handling:

for event in pygame.event.get():
    if event.type == QUIT:
        pygame.quit(); sys.exit()
    if event.type == KEYDOWN and event.key == K_ESCAPE:
        pygame.quit(); sys.exit()

This will keep your event queue current and quit if you click the little "X"
or press ESCAPE.  Notice that an event is only sent once, and so will not
continue to be in the queue on the next check (for example, you wouldn't
want to use code like this to move a character by holding a key down).  If
you want continuous querying, check attributes, not events, like
pygame.mouse.get_pressed(), pygame.key.get_pressed(), etc.  This is what you
were doing, but you left out the event processing, which is necessary in all
cases.

This should get you started
Ian

Reply via email to