Loop for ever

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

while (!quitProgram) {

   SDL_Event event;

do{ SDL_GetMouseState(&x, &y);

// first loop for ever

for (;;){

 SDL_BlitSurface(scroll_surface, &First, temp_surface, 0);
 SDL_BlitSurface(scroll_surface, &ScrollFrom, scroll_surface, 0);
 SDL_BlitSurface(temp_surface, &First, scroll_surface, &Last);
 SDL_BlitSurface(scroll_surface, 0, screen, 0);
 SDL_Flip(screen);

if(SDL_PollEvent(&event) > 0) {

if(event.type == SDL_MOUSEBUTTONDOWN ) {
   break;
   }
}

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

ppap_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

|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

while (!quitProgram) {

  SDL_Event event;

do{ SDL_GetMouseState(&x, &y);

// first loop for ever

for (;;){

SDL_BlitSurface(scroll_surface, &First, temp_surface, 0);
SDL_BlitSurface(scroll_surface, &ScrollFrom, scroll_surface, 0);
SDL_BlitSurface(temp_surface, &First, scroll_surface, &Last);
SDL_BlitSurface(scroll_surface, 0, screen, 0);
SDL_Flip(screen);

if(SDL_PollEvent(&event) > 0) {

if(event.type == SDL_MOUSEBUTTONDOWN ) {
break;
}
}
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

ppap


Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl