-next-
Handling Events

Using SDL_PollEvent() is useful for when you want your program to be doing other things (handling animations, for example) even when the user isn't doing anything.

Usually, you want to deal with most or all events that might be coming in at once. (For example, if the user is moving the mouse around, you will receive a lot of mouse-motion events.)

/* Handle all events so far: */

while (SDL_PollEvent(&event) != 0)
  {
    ... handle the event
  }