My code for this stage

if (bGameOver)
{
    ClearScreen();
    InitGame();
}
else //player Guess eval
{
    if (Input == HiddenWord)
    {
        PrintLine(TEXT("Yep, thats right\n"));
        PrintLine(TEXT("and with %i chances left!"), Lives);
        EndGame();
    }
    else
    {
             --Lives;
            PrintLine(TEXT("Nope, nice try though. \nTry Again!"));
            PrintLine(TEXT("Now you only have %i chances left"), Lives);
        }
        if (Input.Len() != HiddenWord.Len())
        {
             PrintLine(TEXT("Related - didn't I say it is %i characters?"), HiddenWord.Len());
        }
        if (Lives == 0)
        {
            PrintLine(TEXT("You are all out of chances.\nYou Lose!"));
            EndGame();
        }
    }

}

1 Like

I have updated my code a little bit…I didn’t like how it worked but I am sure there are better ways to do it…is there an else-if or is that just nested if’s?

else //player Guess eval
{
    if (Input == HiddenWord)
    {
        PrintLine(TEXT("Yep, thats right"));
        PrintLine(TEXT("and with %i chances left!"), Lives);
        EndGame();
    }
    else
    {
             --Lives;
             if (Lives > 1)
             {
                 PrintLine(TEXT("Nope, nice try though\nChance Lost\nRemaining chances: %i"), Lives);
             }
             if (Lives == 1)
             {
                 PrintLine(TEXT("Ok, settle down\nThis is your LAST CHANCE"));
             }
             if (Lives == 0)
             {
                 PrintLine(TEXT("I see you are all out of chances.\nYou Lose!"));
                 EndGame();
             }
        }
        if (Input.Len() != HiddenWord.Len())
        {
             PrintLine(TEXT("Related - didn't I say it is %i characters?"), HiddenWord.Len());
        }
    }

}

Privacy & Terms