diff options
| -rw-r--r-- | simon_says.ino | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/simon_says.ino b/simon_says.ino index a1a5f05..85c3ddb 100644 --- a/simon_says.ino +++ b/simon_says.ino @@ -14,6 +14,8 @@ enum class Step { // Maximum number of Simon Says steps constexpr int MAX_STEPS = 10; +int game_steps = 2; + // Simon's steps containers Step simon_steps[MAX_STEPS]; Step user_steps[MAX_STEPS]; @@ -46,7 +48,7 @@ void initialise_array(Step steps[MAX_STEPS]) { size_t array_size(Step steps[MAX_STEPS]) { size_t size = 0; - for (size_t index = 0; index < MAX_STEPS; index += 1) { + for (size_t index = 0; index < game_steps; index += 1) { if (steps[index] != Step::Null) { size += 1; } @@ -76,12 +78,24 @@ void increment_simons_list() { // Print initial menu void menu() { if (flag_drew) { - if (analogRead(0) < 800) { + int user_key = analogRead(0); + + if (user_key > 60 && user_key < 200) { + game_steps += 1; + delay(500); + + if (game_steps > 10) { + game_steps = 1; + flag_drew = false; + } + + print_dialog("Press any to go.", String("Up to step (" + String(game_steps) + ").")); + } else if (user_key < 800) { flag_menu = false; flag_drew = false; } } else { - print_dialog("Press any key to", "begin."); + print_dialog("Press any to go.", String("Up to step (" + String(game_steps) + ").")); flag_drew = true; } @@ -177,7 +191,7 @@ void compare_steps() { print_dialog("Correct!", "Continuing ..."); initialise_array(user_steps); - if (array_size(simon_steps) >= MAX_STEPS) { + if (array_size(simon_steps) >= game_steps || array_size(simon_steps) >= MAX_STEPS) { print_dialog("Correct!", "You won!"); initialise_array(simon_steps); delay(500); |