do
{
if (BFull=Clean())
Sound(KillKeep+=BFull);
if (BSame=CleanSame())
Sound(KillKeep+=BSame);
}
while (BSame||BFull);//当没有满行块和连续的相同图案块时才结束循环
for (int N=Length-2;N>=0;N--)
for (int M=0;M!=Width;M++)
if (st_AllState[M][N]&&!st_AllState[M][N+1]) //不为空的且下面没有块才判断
{
BFall=false;
Blank_LfRt=false;
if (!M||M==Width-1)
{
if (!M&&!st_AllState[M+1][N]||M==Width-1&&!st_AllState[M-1][N])
Blank_LfRt=true;
}
else if (!st_AllState[M-1][N]&&!st_AllState[M+1][N])
Blank_LfRt=true;
CPoint *SP=NULL;
m_hwnd==MainHwnd?SP=PlayerSame:SP=AISame;
if (Blank_LfRt) //左右为空,直接下落
BFall=true;
else //左右不空,判断是否有地基
{
BFoundation=false;
for (int l=M;l>=0;l--) //判断左地基
{
if (!st_AllState[l][N])
break;
if (st_AllState[l][N+1])
BFoundation=true;
}
for (int r=M;r<=Width-1;r++) //判断右地基
{
if (!st_AllState[r][N])
break;
if (st_AllState[r][N+1])
BFoundation=true;
}
if (!BFoundation)
BFall=true;
}
for (int index=0;index<=SameIndex;index++)
{
if (M==SP[index].x&&N<=SP[index].y)
BFall=true;
}
}
if (BFall)
{
Repeat=true;
st_AllState[M][N+1]=st_AllState[M][N];
st_AllState[M][N]=0;
FallBlinkStruct *FBall=new FallBlinkStruct();
if (!FBall)
MessageBox(0,"内存不足",0,0);
FBall->hwnd=m_hwnd;
FBall->st_back=st_BackGround;
FBall->CurP.x=M;
FBall->CurP.y=N;
CreateThread(NULL,NULL,FallBlink,(void*)FBall,NULL,NULL);
}
}
if (Repeat)
Fall();
}