fix(MCU课设): 修复一个方块移动的bug
This commit is contained in:
parent
8c19878cc9
commit
8e4172d69d
2 changed files with 755 additions and 733 deletions
File diff suppressed because it is too large
Load diff
|
@ -163,10 +163,16 @@ 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;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void moveRightPiece()
|
void moveRightPiece()
|
||||||
|
@ -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;
|
||||||
|
@ -200,12 +212,12 @@ void judgeBlock()
|
||||||
}
|
}
|
||||||
//计数足则整体下移
|
//计数足则整体下移
|
||||||
if(count == 8)
|
if(count == 8)
|
||||||
{
|
{
|
||||||
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];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in a new issue