Example #1
0
        public bool GetLineWallIntersectionPosition(Line line, ref Vector2 newPosition)
        {
            // Make sure the line go out of the screen
            var maxDistance = (float)Math.Sqrt(
                GameConfig.VirtualResolution.X * GameConfig.VirtualResolution.X +
                GameConfig.VirtualResolution.Y * GameConfig.VirtualResolution.Y
                );
            var direction = Vector2.Normalize(line.Second - line.First);

            line.Second += (direction * maxDistance);

            return
                (MathExtension.LinesIntersect(_bottomWallLine, line, ref newPosition) ||
                 MathExtension.LinesIntersect(_leftWallLine, line, ref newPosition) ||
                 MathExtension.LinesIntersect(_rightWallLine, line, ref newPosition) ||
                 MathExtension.LinesIntersect(_upWallLine, line, ref newPosition));
        }