 
 
 /**
+ * Run the 'Simon Says' game.
+ */
+void playGame(int *pattern) {
+
+    // Set game parameters then begin.
+    int lives = TOTAL_LIVES;
+    int currentLevel = 1;
+    while (lives > 0 && currentLevel < TOTAL_LEVELS) {
+
+        // Display the pattern.
+        for (int lvl = 0; lvl < currentLevel; lvl++) {
+
+            // Blink the LED.
+            digitalWrite(pattern[lvl], HIGH);
+            delay(GAME_SPEED);
+            digitalWrite(pattern[lvl], LOW);
+
+            // Do not wait after blinking the final pattern LED.
+            if (lvl + 1 != currentLevel) delay(GAME_SPEED);
+        }
+
+        // Check player input.
+        if (verifyPlayerInput(pattern, currentLevel)) {
+
+            // The player was correct; move to the next level.
+            currentLevel++;
+
+        // The player was incorrect; subtract a life.
+        } else {
+
+            // Turn on the next red LED.
+            if (lives == TOTAL_LIVES) digitalWrite(RED_1, HIGH);
+            else if (lives == TOTAL_LIVES - 1) digitalWrite(RED_2, HIGH);
+            else if (lives == TOTAL_LIVES - 2) digitalWrite(RED_3, HIGH);
+            delay(LIGHT_DELAY);
+
+            // Remove a life from the current total.
+            lives--;
+        }
+    }
+}
+
+
+/**
  * Cycles LEDs on and off in a decorative pattern while waiting for game start.
  */
 void playLightShow() {

 * Author: David Timmons ( http://david.timmons.io )
 * License: MIT
 */

// Turn debug mode on or off.
const boolean DEBUG = true;


// Define game settings.
const int LIGHT_DELAY = 700;
const int GAME_SPEED = 700;
const int TOTAL_LEVELS = 128;
const int TOTAL_LIVES = 3;
boolean gameStart = false;


