我正在为一个项目制作俄罗斯方块克隆。我几乎完成了,但我的清晰线条课程有一个我无法摆脱的错误。我制作了一个 10*20 的网格,将精灵绘制到其中。当我在地板上找到一条线时,它可以正常工作,但在此之上它只会删除该线并将其下方的所有内容也向下移动。这是我的明线类的代码:
public static void ClearLines()
{
for (int CountY = Game1.LandedBlocks.GetLength(1) - 1; CountY >= 0; CountY--)
{
bool clearLine = true;
for (int CountX = 0; CountX < Game1.LandedBlocks.GetLength(0); CountX++)
{
clearLine &= Game1.LandedBlocks[CountX, CountY] != -1;
}
if (clearLine)
{
for (int CountX = 0; CountX < Game1.LandedBlocks.GetLength(0); CountX++)
{
Game1.LandedBlocks[CountX, CountY] = -1;
}
for (int y = Game1.LandedBlocks.GetLength(1) - 1; y > 0; y--)
{
for (int CountX = 0; CountX < Game1.LandedBlocks.GetLength(0); CountX++)
{
Game1.LandedBlocks[CountX, y] = Game1.LandedBlocks[CountX, y - 1];
}
}
CountY++;
Game1.rows++;
Game1.score += 100;
}
}
}
如果有人能阐明该怎么做,我将不胜感激。我已经尝试了很多,但没有任何效果:(