我正在制作一个游戏,使用Console.Write()重新绘制游戏场景不太好,有没有更快的方法可以重新绘制整个场景而不会让它看起来"卡顿"? 游戏场景中几乎所有的东西都在移动,但只有在与0不同的元素处才有物体...(如果我的描述不足以说明问题,您可以在http://pastebin.com/TkPd37xD中查看完整代码)
for (int Y = 0; Y < playfield.GetLength(0); Y++)
{
for (int X = 0; X < playfield.GetLength(1); X++)
{
//destroying the row when it reaches the top
if (playfield[0, X] != 0)
{
for (int i = 0; i < playfield.GetLength(1); i++)
{
playfield[0, X] = 0;
Console.SetCursorPosition(X, 0);
Console.Write(" ");
}
}
if (playfield[Y, X] == 3)
{
playfield[Y - 1, X] = 3;
playfield[Y, X] = 0;
}
else if (playfield[Y, X] == 1)
{
Console.SetCursorPosition(X, Y - 1);
Console.Write("=");
playfield[Y - 1, X] = 1;
Console.SetCursorPosition(X, Y);
Console.Write(" ");
playfield[Y, X] = 0;
}
else if (playfield[Y, X] == 0)
{
Console.SetCursorPosition(X, Y);
Console.Write(" ");
}
}
}