示例#1
0
        private static void MakeMove(PlayerCoord currentPos, char[,] matrix, string command)
        {
            switch (command)
            {
            case "up":
                if (currentPos.Xpos == 0)
                {
                    currentPos.Xpos = matrix.GetLength(0);
                }
                currentPos.Xpos--;
                break;

            case "down":
                currentPos.Xpos++;
                if (currentPos.Xpos == matrix.GetLength(0))
                {
                    currentPos.Xpos = 0;
                }
                break;

            case "left":
                if (currentPos.Ypos == 0)
                {
                    currentPos.Ypos = matrix.GetLength(1);
                }
                currentPos.Ypos--;
                break;

            case "right":
                currentPos.Ypos++;
                if (currentPos.Ypos == matrix.GetLength(1))
                {
                    currentPos.Ypos = 0;
                }
                break;
            }
        }
示例#2
0
 private static bool CheckForCollisionWithTrail(PlayerCoord currentPos, char[,] matrix, char playerTrail)
 {
     return(matrix[currentPos.Xpos, currentPos.Ypos] != '*' && matrix[currentPos.Xpos, currentPos.Ypos] != playerTrail);
 }