I wanted to vary my Triple X intro message. So I created an if statement in the Intro function that read a different message depending on if it was the start of the game or the start of a higher level. However, these messages sounded really odd if they were repeated when the game repeated after a failed attempt at a given level.
So, I added a second parameter being sent from the main function , called Try . I also added a second if statement in the main function similar to the if statement that increased Difficulty level if a level was passed. This second if statement increased the Try level if false was returned from the game after a failed attempt at a level. Additionally, a second statement was written into the if statement that increased the Difficulty for a passing level that also reset Try to 1.
In other words, if the user passed the level, true was returned and the Difficulty level was increased and Try was reset to 1. If the user failed the level, false was returned and the Try number increased.
Finally, at the start of my game function, I added an if statement before the intro function to only run the intro if it was the first Try (i.e Try == 1).
In other words, the intro statement didn’t repeat if the user was repeating the level.
This allowed me to keep my messages varied and interesting while avoiding awkward repeating patterns.