[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] keyboard input and mouse
After you handle specific events, you should clear the event queue
of all others. (Seeing as how you arent using them.)
I'm guesing the queue is getting filled up with unhandled, uncleared
mouse move events.
My event handling code looks like this:
in game loop:
# Handle user input.
InputHandler.update() # < --- this does the pygame.event.get
for keydown events.
# Handle quit event (generated by closing pygame window, etc)
if pygame.event.get([QUIT,]):
return False
# Clear all other events from the queue.
pygame.event.clear()
Hope that helps,
- Jacob
--- Michael <mogmios@mlug.missouri.edu>
What else is the loop doing? If you're processing
one input event, doing
something, doing output, and looping then if doing
something or output
takes a long time then input processing might seem
sluggish. As was
suggested before you should only watch events you're
actually interested
in. Also try to break whatever processing and output
you're doing up so
that it doesn't take to long in an individual cycle.
Is there anywhere
you're program is stopping to wait for a certain
event or anything like
that? If so then that's obviously a problem.
No, nothing blocks for an event, my event loop is:
for event in pygame.event.get([pygame.KEYDOWN,
pygame.KEYUP]):
if event.type == pygame.KEYDOWN:
# ...
elif event.type == pygame.KEYUP:
# ...
Till now I don't need mouse, so in my program there is
nothing about it, but moving it during the program
cause the previuos call to get() returning no data
____________________________________________________________
Yahoo! Companion - Scarica gratis la toolbar di Ricerca di Yahoo!
http://companion.yahoo.it