I am making a game and need to ask the user which direction they want to move and store it as a char (L, R, U, D).
The char will be passed to this method:
static void Movement(int n, int rolled, char direction)
{
Console.WriteLine("Making a move for " + players[n].Name);
if (direction == 'u' || direction == 'U')
{
if (players[n].Y - rolled < 0)
{
players[n].Y = players[n].Y + 8 - rolled;
}
else
players[n].Y = players[n].Y - rolled;
}
else if (direction == 'd' || direction == 'D')
{
if (players[n].Y + rolled > 7)
{
players[n].Y = players[n].Y - 8 + rolled;
}
else
players[n].Y = players[n].Y + rolled;
}
else if (direction == 'l' || direction == 'L')
{
if (players[n].X - rolled < 0)
{
players[n].X = players[n].X + 8 - rolled;
}
else
players[n].X = players[n].X - rolled;
}
else if (direction == 'r' || direction == 'R')
{
if (players[n].X + rolled > 7)
{
players[n].X = players[n].X - 8 + rolled;
}
else
players[n].X = players[n].X + rolled;
}
Console.WriteLine(" Please pick a direction: (U,D,L,R");
char direction = Console.ReadLine();//this gives me an error
Console.ReadLine() gives me an error, because it returns a string. How do I read a value in as a char and store it in direction?