fix(MCU课设): 修复一个方块移动的bug

This commit is contained in:
iridiumR 2022-06-06 17:03:03 +08:00
parent 8c19878cc9
commit 8e4172d69d
2 changed files with 755 additions and 733 deletions

File diff suppressed because it is too large Load diff

View file

@ -163,6 +163,12 @@ void moveLeftPiece()
for(i = 0; i < MAX_X; i++) for(i = 0; i < MAX_X; i++)
for(j = 0; j < MAX_Y; j++) for(j = 0; j < MAX_Y; j++)
if(base[i][j] == 2 && !isIegal(i - 1, j)) if(base[i][j] == 2 && !isIegal(i - 1, j))
{
return;
}
for(i = 0; i < MAX_X; i++)
for(j = 0; j < MAX_Y; j++)
if(base[i][j] == 2)
{ {
base[i - 1][j] = 2; base[i - 1][j] = 2;
base[i][j] = 0; base[i][j] = 0;
@ -175,7 +181,13 @@ void moveRightPiece()
char i, j; char i, j;
for(i = MAX_X - 1; i >= 0; i--) for(i = MAX_X - 1; i >= 0; i--)
for(j = MAX_Y - 1; j >= 0; j--) for(j = MAX_Y - 1; j >= 0; j--)
if(base[i][j] == 2 && isIegal(i + 1, j)) if(base[i][j] == 2 && !isIegal(i + 1, j))
{
return;
}
for(i = MAX_X - 1; i >= 0; i--)
for(j = MAX_Y - 1; j >= 0; j--)
if(base[i][j] == 2 )
{ {
base[i + 1][j] = 2; base[i + 1][j] = 2;
base[i][j] = 0; base[i][j] = 0;
@ -203,7 +215,7 @@ void judgeBlock()
{ {
score++; score++;
for(k = 0; k < MAX_X; k++) for(k = 0; k < MAX_X; k++)
for(h = j ; h < MAX_Y-1; h++) for(h = j ; h < MAX_Y - 1; h++)
base[k][h] = base[k][h + 1]; base[k][h] = base[k][h + 1];
} }