Archived

This topic is now archived and is closed to further replies.

The obscure art of makin' a menu

This topic is 5897 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

(Previously posted on GCUK forums - www.gamecoding.co.uk/forums) This one another of my problems that''ve been bugging me off for the last weeks: while(1){ if(key[KEY_UP] && (p > 0)){ poll_keyboard(); p--; } if(key[KEY_DOWN] && (p < 2)){ poll_keyboard(); p++; } if(key[KEY_ENTER]){ switch(p){ case 0: // New Game // caca break; case 1: // Credits // caca break; case 2: // Exit // caca break; } } } So? Yep. That menu won''t work. I mean the keyboard reads, but the last if-statement don''t work. Normally the while()-sling should exit, but nothing happens. Help? //toki

Share this post


Link to post
Share on other sites
I think the breaks you put in that switch-thingy just break out of the switch loop, not the while loop. You could build the while loop like this:
  
while( !bDone )
{
}


Then in the switch statement you could set bDone to true, and the while loop would end.

-----------------------------
Jappie
BabJap Productions

"There''s no such things as bugs; they''re just unintentional extra features"

Share this post


Link to post
Share on other sites
quote:
Original post by Freeride Designs
Or you could have

continue;
break;


That break would never execute, since as soon as the continue is reached, you jump to the conditional in the while. The loop would still be infinite.

Jappie has a good solution.

Share this post


Link to post
Share on other sites