I managed to do most of the code on my own, slowly working my way through the code, making mistakes, but trying to logically figure out where and why I went wrong and how to fix it. However, I came to a point where I had to consult the lectures video in order to continue on.
Where did I have difficulties? Three things, two silly mistakes and a location issue.
- Silly mistake: I was checking if (Lives >= 0) then end game. Which, of course, means that the game will always end, being greater than and equal to zero.
- Silly mistake: I made the EndGame ‘If’ statement and the ‘Lives’ check on the same level of code- not an if nested in an if statement. So It would check the word, and then do end game as if the lives were now >= 0.
- Location: I placed the “–Lives” code within the check HiddenWord if statement. What did it do? Nothing. Lives were not negated, but the game would still end due to silly mistakes 1 and 2.
After getting the code behaving correctly I wanted to see what would happen if I modified my silly mistake 1 and 2 “Lives” check to be == 0. I placed the ‘if’ below the HiddenWord Check and removed the ‘else’ statement.
It worked out fine using two ifs and a --Live above them. The only issue I had after that was message redundancy:
Sorry, guess again, you have 0 lives left. You have no more lives left!