code doesn't work as expected

Why? I wanted the function checkWin() to return true if the player guessed the number... The player should guess the number using LEFT arrow and RIGHT arrow...
The function IsKeyPressed() is using GetAsincKeyState() function.
here is the code that is called:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//inside checkWin() function
 else if(Phase==PHASE_DUBLAJ) {
            colorChoice=getDublajChoice();
            bool alreadyTried=false;
        do {

        if(IsKeyPressed(VK_LEFT)) {  alreadyTried==true; plrDecision=RED; }
        if(IsKeyPressed(VK_RIGHT)){  alreadyTried==true; plrDecision=BLACK;}

            //if the player was right he wins..
            if(alreadyTried && plrDecision==colorChoice) {
            plrDecision=3;
            return true;
            }
            //you you already tried your luck and missed .. return false
            if(alreadyTried && plrDecision!=colorChoice) return false;
            }//end of do-while loop
        while(!alreadyTried || !IsKeyPressed(VK_ESCAPE) || !IsKeyPressed(VK_LEFT) || !IsKeyPressed(VK_RIGHT) || !IsKeyPressed(VK_DOWN));
        }

here is the code that calls it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
                //if the player guessed ... double his money
                if(game.checkWin(Phase, player.decision)) {
                    cout << " YOU WON: ";
                    game.totalScore*=2;
                    cout << game.totalScore;
                    cout << endl;
                    system("pause");
                }
                else {
                     cout << " YOU LOST ALL THE MONEY! it was: " << game.colorChoice;
                     game.totalScore=0; //otherwise he loses all the money!
                     Phase=PHASE_FRUCTE;
                     system("pause");
                     break;

                }


                }
                //if the player can no longer double.. stop him and give him the money gained
                else {
                    //handle win(give the player the money and reset the score)
                    player.handleWin(game.totalScore);

                    //reset the phase to fruits
                    Phase=PHASE_FRUCTE;
                    break;
                }

Last edited on
omg... this is sooo embarasing :|
1
2
        if(IsKeyPressed(VK_LEFT)) {  alreadyTried==true; plrDecision=RED; }  //already == ?! wtf :)
        if(IsKeyPressed(VK_RIGHT)){  alreadyTried==true; plrDecision=BLACK;}


changed
1
2
        if(IsKeyPressed(VK_LEFT)) {  alreadyTried=true; plrDecision=RED; }  
        if(IsKeyPressed(VK_RIGHT)){  alreadyTried=true; plrDecision=BLACK;}
Topic archived. No new replies allowed.