Simplified squaresInDirection.