Example #1
0
 //moves shape right
 public string[][] moveRight(string[][] grid)
 {
     foreach (Point p in CurrentPoints)
     {
         if (p.Y >= 0)
         {
             grid[p.Y][p.X] = "";
         }
     }
     Point[] pts = CurrentPoints;
     if (canMoveRight(CurrentPoints, grid))
     {
         for (int x = 0; x < CurrentPoints.Count(); x++)
         {
             if (CurrentPoints[x].X < 19)
             {
                 CurrentPoints[x].X += 1;
                 Point p = CurrentPoints[x];
                 grid[p.Y][p.X] = ShapeColor;
             }
         }
     }
     else
     {
         foreach (Point p in pts)
         {
             if (p.Y >= 0)
             {
                 grid[p.Y][p.X] = ShapeColor;
             }
         }
     }
     return(grid);
 }
Example #2
0
 //moves shape down
 public string[][] moveDown(string[][] grid)
 {
     Point[] pts = CurrentPoints;
     foreach (Point p in CurrentPoints)
     {
         if (p.Y >= 0)
         {
             grid[p.Y][p.X] = "";
         }
     }
     if (canMoveBelow(CurrentPoints, grid))
     {
         for (int x = 0; x < CurrentPoints.Count(); x++)
         {
             CurrentPoints[x].Y += 1;
             Point p = CurrentPoints[x];
             if (p.Y >= 0)
             {
                 grid[p.Y][p.X] = ShapeColor;
             }
         }
     }
     else
     {
         foreach (Point p in pts)
         {
             if (p.Y >= 0)
             {
                 grid[p.Y][p.X] = ShapeColor;
             }
         }
     }
     return(grid);
 }