   // first we clear our screen to black
   arduboy.clear();
 
-  DrawFrame();
-
-  CollisionDetection();
-
-  if(arduboy.pressed(RIGHT_BUTTON)) {
-    p1.dir = 'R';
-  }
-
-  if(arduboy.pressed(LEFT_BUTTON)) {
-    p1.dir = 'L';
-  }
-
-  if(arduboy.pressed(UP_BUTTON)) {
-    p1.dir = 'U';
-  }
-
-  if(arduboy.pressed(DOWN_BUTTON)) {
-    p1.dir = 'D';  
-  }
-
-  switch(p1.dir)
-  {
-    case 'U':
-      if(p1.Y > minY)
-      {
-        p1.Y -= 1;
-      }
+  if(gameRunning == true)
+  {
+    DrawFrame();
+  
+    CollisionDetection();
+  
+    if(arduboy.pressed(RIGHT_BUTTON)) {
+      p1.dir = 'R';
+    }
+  
+    if(arduboy.pressed(LEFT_BUTTON)) {
+      p1.dir = 'L';
+    }
+  
+    if(arduboy.pressed(UP_BUTTON)) {
+      p1.dir = 'U';
+    }
+  
+    if(arduboy.pressed(DOWN_BUTTON)) {
+      p1.dir = 'D';  
+    }
+  
+    switch(p1.dir)
+    {
+      case 'U':
+        if(p1.Y > minY)
+        {
+          p1.Y -= 1;
+        }
+        break;
+      case 'D':
+        if(p1.Y < maxY)
+        {
+          p1.Y += 1;
+        }
+        break;
+      case 'L':
+        if(p1.X > minX)
+        {
+          p1.X-= 1;
+        }
+        break;
+      case 'R':
+        if(p1.X < maxX)
+        {
+          p1.X+= 1;
+        }
+      
       break;
-    case 'D':
-      if(p1.Y < maxY)
-      {
-        p1.Y += 1;
-      }
-      break;
-    case 'L':
-      if(p1.X > minX)
-      {
-        p1.X-= 1;
-      }
-      break;
-    case 'R':
-      if(p1.X < maxX)
-      {
-        p1.X+= 1;
-      }
-    
-    break;
-  }
-
-  arduboy.drawPixel(p1.X, p1.Y, 1);
-  arduboy.drawPixel(foodLocation.X, foodLocation.Y, 1);
-  DrawTail();
-  if(p1.X != previousPosition.X || p1.Y != previousPosition.Y)
-  {
-    previousPosition.X = p1.X;
-    previousPosition.Y = p1.Y;
-    LogMove();
-  }
-  
-  
-  arduboy.setCursor(63, 0);  
-  arduboy.print("Score ");
-
-  char scoreBuff[5];
-  sprintf(scoreBuff, "%05d", score);
-  
-  arduboy.print(scoreBuff);
+    }
+  
+    arduboy.drawPixel(p1.X, p1.Y, 1);
+    arduboy.drawPixel(foodLocation.X, foodLocation.Y, 1);
+    
+    if(p1.X != previousPosition.X || p1.Y != previousPosition.Y)
+    {
+      previousPosition.X = p1.X;
+      previousPosition.Y = p1.Y;
+      LogMove();
+    }
+    DrawTail();
+    
+    
+    arduboy.setCursor(63, 0);  
+    arduboy.print("Score ");
+  
+    char scoreBuff[5];
+    sprintf(scoreBuff, "%05d", score);
+    
+    arduboy.print(scoreBuff);
+  }
+  else
+  {
+    arduboy.setCursor(20, 20);  
+    arduboy.print("Game Over");
+    
+    arduboy.setCursor(20, 40);  
+    arduboy.print("Score ");
+  
+    char scoreBuff[5];
+    sprintf(scoreBuff, "%05d", score);
+    
+    arduboy.print(scoreBuff);
+  }
+
+  
   
 
   // then we finaly we tell the arduboy to display what we just wrote to the display

// make an instance of arduboy used for many functions
Arduboy arduboy;

int maxX = 127;
int minX = 0;
int maxY = 63;
int minY = 10;

class coords
{
  public:
  int X = 0;
  int Y = 0; 
};

typedef struct coords Coords;

struct player
{
  int X = 0;
  int Y = 0;
  char dir = 'R';
  int Len = 0;
  static const int MaxLength = 10;
  Coords *Moves[MaxLength] = {NULL};
};


    LogMove();
    GenerateFood();
  }

  //Check if hit wall

  if(p1.X >= maxX || p1.X <= minX || p1.Y >= maxY || p1.Y <= minY)
  {
    gameRunning = false; 
  }

  //Check if hit tail
}

void DrawTail()
