Old Code
Old Code
using System.ComponentModel.DataAnnotations;
using System.Globalization;
class Program
{
static void Main(string[] args)
{
string left;
string right;
string mid;
string screen;
int[,] array2D = new int[10, 10];
int player = 3;
int playerX = 0;
int playerY = 0;
int Disp_distance;
string cLeft = "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[";
string mLeft = "[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ ";
string fleft = "[ { [ { [ { [ { [ { [ { [ {";
string cmid = "||||||||||||||||||||||||||||||||||||||||";
string Mmid = "| | | | | | | | | | || | | | | | | | | |";
string fmid = "| | | | | | | | | | | | | |";
string cright = "]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]";
string mright = "] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ";
string fright = "] } ] } ] } ] } ] } ] } ] ]";
DisplayArray(array2D);
int Facer;
while (true)
{
ConsoleKeyInfo keyInfo = Console.ReadKey(true);
switch (keyInfo.Key)
{
case ConsoleKey.UpArrow:
MovePlayer(array2D, ref playerX, ref playerY, -1, 0);
Facer = 10;
break;
case ConsoleKey.DownArrow:
MovePlayer(array2D, ref playerX, ref playerY, 1, 0);
Facer = 20;
break;
case ConsoleKey.LeftArrow:
MovePlayer(array2D, ref playerX, ref playerY, 0, -1);
Facer = 30;
break;
case ConsoleKey.RightArrow:
MovePlayer(array2D, ref playerX, ref playerY, 0, 1);
Facer = 40;
break;
default:
break;
}
Console.Clear();
Screen(Disp_distance, Disp_distance2, Disp_distance3, mid, left, right,
cleft, mleft, fleft, cmid, Mmid, fmid, cright, mright, fright, screen);
DisplayArray(array2D);
}
}
static void Screen(int Disp_distance, int Disp_distance2, int Disp_distance3,
string mid, string left, string right, string cleft, string mleft, string fleft,
string cmid, string Mmid, string fmid, string cright, string mright, string fright,
string screen)
{
switch (Disp_distance)
{
case 0: mid = cmid; break;
case <= 3: mid = Mmid; break;
case <= 5: mid = fmid; break;
}
switch (Disp_distance2)
{
case 0: left = cleft; break;
case <= 3: left = mleft; break;
case <= 5: left = fleft; break;
}
switch (Disp_distance3)
{
case 0: right = cright; break;
case <= 3: right = mright; break;
case <= 5: right = fright; break;
}
screen = left + mid + right;
Console.Write(screen);
}
static void DisplayArray(int[,] array )
{
int rows = array.GetLength(0);
int cols = array.GetLength(1);
}
static void MovePlayer(int[,] array, ref int playerX, ref int playerY, int
deltaX, int deltaY)
{
int newX = playerX + deltaX;
int newY = playerY + deltaY;
if (newX >= 0 && newX < array.GetLength(0) && newY >= 0 && newY <
array.GetLength(1) && array[newX, newY] != 1)
{
array[playerX, playerY] = 0;
playerX = newX;
playerY = newY;
array[playerX, playerY] = 3;
}
}
static void Player_pos_to_disp(int[,] array, ref int playerX, ref int playerY,
int deltaX, int deltaY, int Facer, int[,] array2D, int Disp_distance, int
Disp_distance2, int Disp_distance3, string mid, string left, string right, string
cleft, string mleft, string fleft, string cmid, string Mmid, string fmid, string
cright, string mright, string fright, string screen)
{
bool foundX = false;
bool foundY = false;
int d;
int I;
int c;
int k;
while (true)
{
switch (Facer)// these need to be done and it will be hell i trust in
that
{
case 10:
for (int i = playerY; foundY = false; i++)
{
if (array2D[playerX, i] == 1)//1,1
{
foundY = true;
d = i;
if (foundY = true)
{
int distance = d - playerY;
switch (distance)
{
case 0:
Disp_distance = 0;
break;
case 1:
Disp_distance = 1;
break;
case <= 3:
Disp_distance = 2;
break;
case <= 5:
Disp_distance = 3;
break;
}
}
}
if (array2D[playerX - 1, i] == 1)//1,2
{
foundY = true;
d = i;
if (foundY = true)
{
int distance = d - playerY;
switch (distance)
{
case 0:
Disp_distance2 = 0;
break;
case 1:
Disp_distance2 = 1;
break;
case <= 3:
Disp_distance2 = 2;
break;
case <= 5:
Disp_distance2 = 3;
break;
}
}
}
if (array2D[playerX + 1, i] == 1)//1,3
{
foundY = true;
d = i;
if (foundY = true)
{
int distance = d - playerY;
switch (distance)
{
case 0:
Disp_distance3 = 0;
break;
case 1:
Disp_distance3 = 1;
break;
case <= 3:
Disp_distance3 = 2;
break;
case <= 5:
Disp_distance3 = 3;
break;
}
}
}
break;
case 20:
for (int i = playerY; foundY = false; i--)
{
if (array2D[playerX, i] == 1)// 2,1
{
foundY = true;
I = i;
if (foundY = true)
{
int distance2 = i - playerY;
switch (distance2)
{
case 0:
Disp_distance = 0;
break;
case 1:
Disp_distance = 1;
break;
case <= 3:
Disp_distance = 2;
break;
case <= 5:
Disp_distance = 3;
break;
}
}
}
if (array2D[playerX - 1, i] == 1)// 2,2
{
foundY = true;
I = i;
if (foundY = true)
{
int distance2 = i - playerY;
switch (distance2)
{
case 0:
Disp_distance2 = 0;
break;
case 1:
Disp_distance2 = 1;
break;
case <= 3:
Disp_distance2 = 2;
break;
case <= 5:
Disp_distance2 = 3;
break;
}
}
}
if (array2D[playerX + 1, i] == 1)// 2,3
{
foundY = true;
I = i;
if (foundY = true)
{
int distance2 = i - playerY;
switch (distance2)
{
case 0:
Disp_distance3 = 0;
break;
case 1:
Disp_distance3 = 1;
break;
case <= 3:
Disp_distance3 = 2;
break;
case <= 5:
Disp_distance3 = 3;
break;
}
}
}
}
break;
case 30:
for (int i = playerX; foundY = false; i--)
{
if (array2D[i, playerY] == 1)//3,1
{
foundX = true;
c = i;
if (foundX = true)
{
int distance3 = c - playerY;
switch (distance3)
{
case 0:
Disp_distance = 0;
break;
case 1:
Disp_distance = 1;
break;
case <= 3:
Disp_distance = 2;
break;
case <= 5:
Disp_distance = 3;
break;
}
}
}
if (array2D[i, playerY - 1] == 1)//3,2
{
foundX = true;
c = i;
if (foundX = true)
{
int distance3 = c - playerY;
switch (distance3)
{
case 0:
Disp_distance2 = 0;
break;
case 1:
Disp_distance2 = 1;
break;
case <= 3:
Disp_distance2 = 2;
break;
case <= 5:
Disp_distance2 = 3;
break;
}
}
}
if (array2D[i, playerY + 1] == 1)//3,3
{
foundX = true;
c = i;
if (foundX = true)
{
int distance3 = c - playerY;
switch (distance3)
{
case 0:
Disp_distance3 = 0;
break;
case 1:
Disp_distance3 = 1;
break;
case <= 3:
Disp_distance3 = 2;
break;
case <= 5:
Disp_distance3 = 3;
break;
}
}
}
}
break;
case 40:
for (int i = playerY; foundX = false; i++)
{
if (array2D[i, playerY] == 1)//4,1
{
foundX = true;
k = i;
if (foundX = true)
{
int distance4 = k - playerY;
switch (distance4)
{
case 0:
Disp_distance = 0;
break;
case 1:
Disp_distance = 1;
break;
case <= 3:
Disp_distance = 2;
break;
case <= 5:
Disp_distance = 3;
break;
}
}
}
if (array2D[i, playerY - 1] == 1)//4,1
{
foundX = true;
k = i;
if (foundX = true)
{
int distance4 = k - playerY;
switch (distance4)
{
case 0:
Disp_distance2 = 0;
break;
case 1:
Disp_distance2 = 1;
break;
case <= 3:
Disp_distance2 = 2;
break;
case <= 5:
Disp_distance2 = 3;
break;
}
}
}
if (array2D[i, playerY + 1] == 1)//4,2
{
foundX = true;
k = i;
if (foundX = true)
{
int distance2 = k - playerY;
switch (distance2)
{
case 0:
Disp_distance3 = 0;
break;
case 1:
Disp_distance3 = 1;
break;
case <= 3:
Disp_distance3 = 2;
break;
case <= 5:
Disp_distance3 = 3;
break;
}
}
}
}
break;
}
}
}
}