Hello there i have one question about loops and
SDL_PollEvent + SDL_PushEvent,
i try to make one small proggram just to lern some things
in my proggram i have 3 loops like this
if (event.type & (SDL_KEYUP | SDL_KEYDOWN))
{
}
}
//secont loop for ever
bla bla
// third loop for ever
bla bla
}while (SDL_PollEvent (&event));
now my problem is that i cant make it work and the 3 loops together
when i press the mouse then i go to the next loop
or if i change the break then i never go to next loop
so far with SDL_PushEvent i cant make it to work
of course this code is never gonna work like this
my question is how can i make this loops work together
and then continue the proggram. is it possible this?
thank you
|while i wouldn’t exactly design it the way you have, to get it working
i’d amend it in the places shown below.
while (!quitProgram)
{
SDL_Event event;
do
{
SDL_GetMouseState(&x, &y);
// first loop for ever
for (;!quitProgram;) // *********** changed this
{
if(SDL_PollEvent(&event) > 0)
{
if(event.type == SDL_MOUSEBUTTONDOWN )
{
break;
}
// *********** added the following
if(event.type & SDL_KEYDOWN && event.key.keysym.sym ==
SDLK_ESCAPE)
{
quitProgram = true;
break;
}
// *********** end added the
}
if (event.type & (SDL_KEYUP | SDL_KEYDOWN))
{
}
}
//secont loop for ever
// third loop for ever
} while (SDL_PollEvent (&event));
} |
petros ppap wrote:>
Hello there i have one question about loops and
SDL_PollEvent + SDL_PushEvent,
i try to make one small proggram just to lern some things
in my proggram i have 3 loops like this
now my problem is that i cant make it work and the 3 loops together
when i press the mouse then i go to the next loop
or if i change the break then i never go to next loop
so far with SDL_PushEvent i cant make it to work
of course this code is never gonna work like this
my question is how can i make this loops work together
and then continue the proggram. is it possible this?
thank you