To detect a "game over" situation, we do the following:
- Declare a variable which I've chosen to name game_over. It's a boolean, and we'll use it to keep track of whether the game has finished or not.
- Created a function I've chosen to name ShowGameOver, which does a series of fillTexts to display an appropriate message. Again, I could have done it inside Do_a_Frame, but it's nice to keep things short and readable.
- In Do_a_Frame, if the game_over flag is true, we call ShowGameOver. Otherwise we do the for-loop that handles all the bats.
- Finally, inside the for-loop, we check each bat to see if it's touching the bug. If it is, we set the game_over flag.