我正在尝试使用开关在控制台应用程序的 8x8 板上移动

I'm trying to get movement on an 8x8 board on console application using a switch

我正在尝试让玩家在 8x8 的板上移动,我有向上移动但我似乎无法找到其他方向,请帮助,初学者

static void MovePlayer(int playerNo, int distance, char direction)
{
 Console.WriteLine("Making a move for " + players[playerNo].Name);

 switch (direction)
{
 case 'U':
 // Moving the player up - need to decrease the value of Y
 // because the origin is the top left hand corner of the board
 players[playerNo].Y = players[playerNo].Y - distance;
 // This might take us off the top of the board, so we need to
 // wrap round
 if (players[playerNo].Y < 0)
 {
 players[playerNo].Y = players[playerNo].Y + 8;
 }
 break;

 case 'D': //down
 players[playerNo].Y = players[playerNo].Y - distance;
 // need to move down - increase Y
 if (players[playerNo].Y > 0)
 {
 players[playerNo].Y = players[playerNo].Y - 8;
 }
 break;
 case 'L':
 players[playerNo].Y = players[playerNo].Y - distance;
 break;

 case 'R':
 break;
 }

您使用的是二维数组来跟踪玩家吗?无论哪种方式,你当然需要两个坐标。 X 和 Y。但实际上,您应该考虑行与列。对于我正在开发的游戏,我在这里做几乎完全相同的事情。然而,我只允许玩家每回合前进一格。

如果我们说 X 是行,Y 是列,要向上移动,必须从 X 中减去,要向下移动,必须对 X 进行加法,要向右移动,必须从 Y 中减去,然后到向左移动你必须添加到 Y。

我假设您使用距离来增加玩家的位置。您在每种情况下都在减去它们。所以,对于向下,你需要增加距离。等等。