[SDL] question about handling events
brian.ripoff at gmail.com
Fri Jul 29 02:30:12 PDT 2011
It sounds like you are running animation in a tight loop. There are a
few downsides to such an approach. One is, as you found, it can be
difficult to control the loop externally. Another is that it prevents
In most interactive programs, you'll want discrete simulation steps
that return control to a "main" loop. So you need to structure your
code so that individual sprites know that they are animating, and
retain enough data between steps to know what to display next.
I'm not sure about your switching window problem, but if you aren't
regularly calling SDL_PumpEvents() (which you usually call implicitly
by calling SDL_PollEvent or SDLWaitEvent) then the window manager
might assume you application is non responsive. Remember when you
switch windows the window manager sends messages to your program, and
unless you let SDL act on these messages it might not work.
As Jonathan mentions, don't worry about your code being not readable.
Many of us have experience helping beginner programmers!
On 28 July 2011 23:34, Ivan Radojkovic <itsa.registers at gmail.com> wrote:
> I am new with SDL.
> I have written an intro to a game, but I cant figure out how to check for
> SDL_QUIT effectively while the animation is running. And the other issue is
> whenever I switch to another window the program stops responding and
More information about the SDL