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
elseif(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;
returntrue;
}
//you you already tried your luck and missed .. return false
if(alreadyTried && plrDecision!=colorChoice) returnfalse;
}//end of do-while loop
while(!alreadyTried || !IsKeyPressed(VK_ESCAPE) || !IsKeyPressed(VK_LEFT) || !IsKeyPressed(VK_RIGHT) || !IsKeyPressed(VK_DOWN));
}
//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;
}