Adding a time-bar
As time is a crucial mechanic in the game, it is necessary to keep the player aware of it. They need to know if their allotted six seconds are about to run out. It will give them a sense of urgency as the end of the game draws near and a sense of accomplishment if they perform well enough to maintain or increase their remaining time.
A drawing of the number of seconds remaining on the screen is not easy to read (when concentrating on the branches) or a particularly interesting way to achieve the objective.
What we need is a time-bar. Our time-bar will be a simple red rectangle, prominently displayed on the screen. It will start off nice and wide but rapidly shrink as time runs out. When the player’s remaining time reaches 0, the time-bar will be gone completely.
At the same time as adding the time-bar, we will add the necessary code to keep track of the player’s remaining time, as well as respond when they run out. Let’s go through...