Hello,
I'm getting better at coding and to learn more I'm writing a game that at this time prints to the serial console
and accepts [y] or [n] input from the keyboard to tell the program what to do.
When I'm done I hope to port it to my LCD shield and use the UP and DOWN buttons for [y] and [n].
With that lead up, there are points in the program where the game play ends before the end of
all the code in void_loop(). There is randomseed data in play so the game may go 1 step
or all the way thru 6 steps before finishing. This makes each game play unique, challenging the player
to make choices for the next move.
At each step, the player is notified if they won or lost.
Then they are asked to play again [y] (of course they do )
I would like at this point to have the program start from scratch at the top of void_loop() again
without running any more code.
Serial.print("You Won!. Game Over");
delay (3000);
Serial.print("Play Again???");
while(!Serial.available()>0) Serial.read(); {
key = Serial.read();
if (key == 'y'){
// EXIT THE PROGRAM AND RESTART FROM THE TOP
//sorry to yell :)
}
I know that a 'break' jumps out of a loop but I'm not jumping from a loop so that won't work.
Most of my steps are wrapped up as functions.
{
step1 ();
step2 ();
step3 ();
//etc, etc
}
Is this a good reason to use a goto label?
have it goto a bailout: label ?
Any other smart ways to do this?
Thanks in advance.
Kevin