using System.Collections.Generic;
using System.Threading.Tasks;
namespace Random100.TraceRay
public static void Main(string[] args)
var arr = new string[20, 20];
Console.WriteLine("\r \n Choose 2 sets of coordinates (x y x1 y1, each number betwee 1 and 18");
bool isLonger = Math.Abs((_x1 - _x) - 1) > Math.Abs((_y1 - _y) - 1);
var xCheck = Math.Abs(_x1 - _x) - 1;
var height = Math.Abs((y1 - y));
for (int i = 0; Math.Abs(i) <Math.Abs( xCheck);)
while (Math.Abs(k) < height)
l = Math.Round((Math.Abs(_x1 - _x) - 1 )/ (Math.Abs(_y1 - _y) - 1) * Math.Abs(k));
if (Math.Abs(i) == l && y != y1)
l = Math.Round((Math.Abs(_y1 - _y) - 1) / (Math.Abs(_x1 - _x) - 1) * Math.Abs(i));
if (Math.Abs(k) == l && x != x1)
arr[y + k, x + (i + 1)] = " O ";
else if (x <= x1 && y >= y1)
arr[y - k, x + (i + 1)] = " O ";
else if (x >= x1 && y <= y1)
arr[y + k, x - (i + 1)] = " O ";
else if (x >= x1 && y >= y1)
arr[y - k, x - (i + 1)] = " O ";
if (i == xCheck + 1 && x != x1)
else if (x == x1 && k == Math.Abs((y1 - y))-1)
arr[y +( k + 1) , x + i ] = " O ";
else if (x <= x1 && y >= y1)
arr[y - (k + 1), x + i ] = " O ";
else if (x >= x1 && y <= y1)
arr[y + (k + 1), x - i ] = " O ";
else if (x >= x1 && y >= y1)
arr[y - (k + 1), x - i ] = " O ";
if (x == x1 && k == Math.Abs((y1 - y))-1)
public static void createArray(string[,] arr)
for (int j = 0; j < 20; j++)
for (int i = 0; i < 20; i++)
for (int i = 1; i < 19; i++)
for (int j = 1; j < 19; j++)
public static void displayArray(string[,] arr)
for (int i = 0; i < 20; i++)
for (int j = 0; j < 20; j++)
Console.Write(arr[i, j]);
public static void chooseCoord(int[] carr, string[,] arr)
string[] input = Console.ReadLine().Split(' ');
for (int i = 0; i < 4; i++)
carr[i] = int.Parse(input[i]);
arr[carr[1], carr[0]] = " X ";
arr[carr[3], carr[2]] = " X ";