 
   // here we set the framerate to 15, we do not need to run at
   // default 60 and it saves us battery life
-  arduboy.setFrameRate(10);
+  arduboy.setFrameRate(30);
 
  StartGame(); 
 }

  // 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;
      }
      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);
  

  // 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;

byte maxX = 127;
byte minX = 0;
byte maxY = 63;
byte minY = 10;
bool gameRunning = true;

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

typedef struct coords Coords;

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

