On Mon, Jan 16, 2012 at 4:27 PM, Ryan Strunk <ryan.str...@gmail.com> wrote:

> I understand the reasoning behind get_pressed. What's the significance of
> while pygame.event.get(): pass
>
Oops.  I meant: "for event in pygame.event.get(): pass"

Is that what you use instead of the for loop to step through the events in
> the queue, or is that the main event loop? Should I be putting that in
> instead of
> for key in pygame.event.get():
> in order to look through all of the generated events?
> Thanks,
> Ryan
>
Briefly:

Every input gets sent to the event queue.  This queue is what
pygame.event.get() returns.  You MUST call this function (or similar)
often, or else the queue will fill up, and you'll get problems.

This can be tedious to use.  In your case, you want something to happen
continuously if both keys are pressed.  Because you're only processing one
event at a time, you can't know if you're pressing two keys.  Moreover, you
can't know that you're holding down a key (you worked around this by adding
the repeat).

The commands like pygame.key.get_pressed() return *instantaneous* values.
 In this case, you can ask it whether any combination of keys are pressed.
 Internally, this works by keeping track of what's happened (e.g., if a
pygame.KEYDOWN event was put into the queue, then PyGame will store a
variable saying so for later use).

Ian

Reply via email to