public boolean canShift(Direction dir)
  {
    int minX = getWidth()*2;
    int maxX = 0;
    int minY = getHeight()*2;
    int maxY = 0;
    
    for (Level l : levels)
    {
      for (Piece p : l.pieces)
      {
        minX = Math.min(minX, p.x);
        minY = Math.min(minY, p.y);
        maxX = Math.max(maxX, p.x+p.type.width*2);
        maxY = Math.max(maxY, p.y+p.type.height*2);
      }
    }
    
    switch (dir)
    {
      case NORTH: return minY >= 2;
      case SOUTH: return maxY <= getHeight()*2 - 2;
      
      case EAST: return maxX <= getWidth()*2 - 2;
      case WEST: return minX >= 2;
      
      default: return false;
    }
  }