     DrawFrame();
   
     if(arduboy.pressed(RIGHT_BUTTON)) {
-      p1.X += 1;
+      if((p1.X) < (maxX - p1.W))
+      {
+        p1.X += 1;
+      }
     }
   
     if(arduboy.pressed(LEFT_BUTTON)) {
-      p1.X -= 1;
-    }
-  
-    if(arduboy.pressed(UP_BUTTON)) {
-//      if(p1.dir != 'D')
-//      {
-//        p1.dir = 'U';
-//      }
-    }
-  
-    if(arduboy.pressed(DOWN_BUTTON)) {
-//      if(p1.dir != 'U')
-//      {
-//        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;
-//    }
+      if(p1.X > 0)
+      {
+        p1.X -= 1;
+      }
+    }
+
+    if(arduboy.pressed(B_BUTTON))
+    {
+      if(fireDelay == 0)
+      {
+        for (int i = 0; i < maxProjs; i++) 
+        {
+          if(projs[i].Active == false)
+          {
+            projs[i].X = p1.X + (p1.W /2);
+            projs[i].Y = p1.Y - 1;
+            projs[i].Active = true;
+            fireDelay = 20;
+            break;
+          }
+        }
+      }
+    }
+  
+  
+
 
     CollisionDetection();
       

void DrawFrame()
{
  //arduboy.drawRect(minX,minY, maxX +1, (maxY - minY) +1, WHITE);

  arduboy.drawSlowXYBitmap(p1.X -2,p1.Y, playerShip, playerWidth, playerHeight, WHITE);
}

// This function runs once in your game.


PROGMEM const unsigned char playerShip [] = {0x10, 0x38, 0x7C, 0xFE};

//byte playerWidth = 7;
//byte playerHeight = 4;

PROGMEM const unsigned char ship1 [] = {0x38, 0x7C, 0xFE, 0xFE, 0x82, 0xC6};

