if and while statement help please

I am trying to get a menu screen before my code runs, this is a snippet of what I have, can anyone tell me what I am doing wrong? When I run it my program runs a frozen white screen.


//global
bool startMenu;

case WM_CREATE:
startMenu = true;



if(startMenu == false)
{
GAME CODE HERE //works fine without menu code...
}
else
{
while(startMenu == true)
{
background1->Draw(hdc);
if(_kbhit())
{
startMenu = false;
}
}
}
First of all, I'm a beginner so i'm just taking a chance at guessing this...
Anyway, you should try changing

1
2
if(startMenu == false)
{


to

1
2
if (startMenu == "start") // Change start to what you want the user to type to begin the game
{


Like I said, I am a beginner at C++, but I think this may work
Well I dont think that will help, I am trying to get the if statement to skip the game code and run a start menu and wait for any key to be pressed, then loop back to the game code when any key is pressed.
1
2
3
4
5
6
7
8
if(startMenu == false)
    //GAME CODE 
else 
    while(startMenu == true){
        background1->Draw(hdc);
        if(_kbhit())
            startMenu = false;
    }


maybe try this?

1
2
3
4
5
6
7
8
9
10
11
while (EXIT == false) {
    if(startMenu == false)
        //GAME CODE 
    else 
        while(startMenu == true){
           while (!_kbhit()) 
                background1->Draw(hdc);
           startMenu = false;
        }
}
return 0;


or,

1
2
3
4
5
6
7
8
9
while (EXIT == false) {
    if(startMenu == false)
        //GAME CODE 
    else 
        background1->Draw(hdc);
    while (!_kbhit()); 
    startMenu = false;
}
return 0;


Last edited on
Topic archived. No new replies allowed.