if (a%S2==0)
{
count2=0;
for (b=0;b<4;b++)
{
p=c[b];q=d[b]+S2;
if (barrier[(p-S1)/S2][(q-S1)/S2].x==p && barrier[(p-S1)/S2][(q-S1)/S2].y==q)
{
for (f=0;f<4;f++)
{
p=c[f];q=d[f];
barrier[(p-S1)/S2][(q-S1)/S2].x=p;
barrier[(p-S1)/S2][(q-S1)/S2].y=q;
barrier[(p-S1)/S2][(q-S1)/S2].z=img11;
}
count2++;
break;
}
}
if (count2!=0)
break;
}
loop2: for (b=0;b<5;b++)
{
d[b]=d[b]+1;
cc[b]=c[b];
dd[b]=d[b];
}
FlushBatchDraw();
if (speed>0)
speed--;
else
Sleep(Time);
putimage(S1+S2,S1+S2,&img1);
}
EndBatchDraw();
//判断游戏结束
for (p=1;p<M;p++)
for (q=1;q<N;q++)
if (barrier[p][q].x==S1+p*S2 && barrier[p][q].y==S1+q*S2)
if (q==1)
{
settextcolor(RED);
settextstyle(40,40,_T("楷体"));
outtextxy(200,Height*1/2,_T("Game Over!"));
for (;;)
getch(); //游戏结束,无论按什么键都没用,窗口不关闭
closegraph(); //没有作用
exit(0); //没有作用
}
for (q=1;q<N;q++)
{
count3=0; //判断某一行是否填满
for (p=1;p<M;p++)
if (barrier[p][q].x==S1+p*S2 && barrier[p][q].y==S1+q*S2)
count3++;
if (count3==M-1)
{
count4++; //用来统计消去的行数
count5++; //计数有几行满了,最多四行
//用get系列来接收哪一行满了
if (count5==1)
get1=q;
else if (count5==2)
get2=q;
else if (count5==3)
get3=q;
else
get4=q;
}
}
if (count5>0)
{
putimage(S1+S2,S1+S2,&img);
if (count5==1)
{
for (p=1;p<M;p++)
for (q=1;q<get1;q++)
functon1(count5);
for (p=1;p<M;p++)
function2(get1);
for (p=1;p<M;p++)
for (q=1;q<get1+1;q++)
function3();
}
if (count5==2)
{
for (p=1;p<M;p++)
{
for (q=1;q<get1;q++)
functon1(count5);
for (q=get1+1;q<get2;q++)
functon1(1);
}
for (p=1;p<M;p++)
{
function2(get1);
function2(get2);
}
for (p=1;p<M;p++)
for (q=1;q<get2+1;q++)
function3();
}
if (count5==3)
{
for (p=1;p<M;p++)
{
for (q=1;q<get1;q++)
functon1(count5);
for (q=get1+1;q<get2;q++)
functon1(2);
for (q=get2+1;q<get3;q++)
functon1(1);
}
for (p=1;p<M;p++)
{
function2(get1);
function2(get2);
function2(get3);
}
for (p=1;p<M;p++)
for (q=1;q<get3+1;q++)
function3();
}
if (count5==4)
{
for (p=1;p<M;p++)
{
for (q=1;q<get1;q++)
functon1(count5);
for (q=get1+1;q<get2;q++)
functon1(3);
for (q=get2+1;q<get3;q++)
functon1(2);
for (q=get3+1;q<get4;q++)
functon1(1);
}
for (p=1;p<M;p++)
{
function2(get1);
function2(get2);
function2(get3);
function2(get4);
}
for (p=1;p<M;p++)
for (q=1;q<get4+1;q++)
function3();
}
for (p=1;p<M;p++)
for (q=1;q<N;q++)
if (barrier[p][q].x==S1+p*S2 && barrier[p][q].y==S1+q*S2) //if判断不能少,曾经犯得错误之一
putimage(barrier[p][q].x,barrier[p][q].y,&barrier[p][q].z);