(I’m still on the same track as the last two questions I’ve asked, I just can’t hit this in the right spot!)
Anyway my question is this: How do I add or only allow certain things to be registered by SDL_WaitEvent?
The current program that I am working on requires to wait for the user to give their input before returning back to the game loop. Now the problem with using PollEvent is that I’m spammed with a bunch of images and currently have no way of waiting for input. The problem with WaitEvent is that it waits for any event. Mouse, keyboard, or anything.
How do I add exceptions to WaitEvent? OR do you guys know of any way to wait for the user to give input?
Please, please be specific.
And if it helps, here is my “gameLoop”.
void game::startLoop()
{
while(QUIT == false)
{
getRoomUpdate();
applySurface(-15, 280, zombie_lefthand, buffer);
applySurface(455, 280, zombie_righthand, buffer);
SDL_Flip(buffer);
while(SDL_WaitEvent(&gameEvent)) //Exceptions!? Wait for input!?
{
switch(gameEvent.type)
{
case SDL_QUIT:
QUIT = true;
break;
}
}
}
}
You probably want the
SDL_EventState()function. The terrible wiki documentation might be able to help get you up to speed. The basic idea, though, is that you simply setSDL_IGNOREorSDL_ENABLEdepending on whether you want to ignore or receive certain events.