该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
void main()//主函数
{
B: start();
int l=draw();
int t=0,m,n,e=0,r;
if(l==2)change(t);
else if(l==1)change1(t);
position p;
srand((unsigned)time(NULL));
MOUSEMSG k;
FlushMouseMsgBuffer();
while(l==2)
{
change(t);
k=GetMouseMsg();
if(k.uMsg==WM_LBUTTONDOWN)
{
if(k.x>=1215)continue;
m=(int)k.x/30,n=(int)k.y/30;
}
else continue;
if(t==0&&f[n][m]==0)//棋手落子
{
f[n][m]=1;
black(m*30+15,n*30+15);
if(black_judge(n,m))
{
setcolor(MAGENTA);
outtextxy(1215,500,"棋手获胜");
setfont(15,0,"楷体");
setcolor(BLUE);
outtextxy(1200,560,"1.按y重新开始!");
outtextxy(1200,590,"2.按其他键结束!");
char d=getch();
if(d=='y'||d=='Y')
{
setbkcolor(0);
cleardevice();
closegraph();
goto B;
}
else goto A;
}
t=1-t;
clear_change(t);
}
change(t);
r=rand()%8;
if(e>0)p=calculate();
else p.x=n+a[r][0],p.y=m+a[r][1];
e++;
if(t==1)//电脑落子
{
white(p.y*30+15,p.x*30+15);
f[p.x][p.y]=-1;
if(white_judge(p.x,p.y))
{
setcolor(MAGENTA);
outtextxy(1215,500,"电脑获胜");
setfont(15,0,"楷体");
setcolor(BLUE);
outtextxy(1200,560,"1.按y重新开始!");
outtextxy(1200,590,"2.按其他键结束!");
char d=getch();
if(d=='y'||d=='Y')
{
setbkcolor(0);
cleardevice();
closegraph();
goto B;
}
else goto A;
}
t=1-t;
clear_change(t);
}
}
while(l==1)
{
k=GetMouseMsg();
if(k.uMsg==WM_LBUTTONDOWN)
{
if(k.x>=1215)continue;
m=(int)k.x/30,n=(int)k.y/30;
}
else continue;
change1(t);
if(t==0&&k.uMsg==WM_LBUTTONDOWN&&f[n][m]==0)//1号棋手落子
{
f[n][m]=1;
black(m*30+15,n*30+15);
if(black_judge(n,m))
{
setcolor(MAGENTA);
outtextxy(1205,500,"1号棋手获胜");
setcolor(BLUE);
outtextxy(1200,560,"1.按y重新开始!");
outtextxy(1200,590,"2.按其他键结束!");
char d=getch();
if(d=='y'||d=='Y')
{
setbkcolor(0);
cleardevice();
closegraph();
goto B;
}
else goto A;
}
t=1-t;
clear_change1(t);
}
change1(t);
D: if(t==1&&f[n][m]==0)//2号棋手落子
{
if(k.uMsg==WM_LBUTTONDOWN)
{
if(k.x>=1215)goto D;
m=(int)k.x/30,n=(int)k.y/30;
}
else goto D;
f[n][m]=-1;
white(m*30+15,n*30+15);
if(white_judge(n,m))
{
setcolor(MAGENTA);
outtextxy(1205,500,"2号棋手获胜");
setcolor(BLUE);
outtextxy(1200,560,"1.按y重新开始!");
outtextxy(1200,590,"2.按其他键结束!");
char d=getch();
if(d=='y'||d=='Y')
{
setbkcolor(0);
cleardevice();
closegraph();
goto B;
}
else goto A;
}
t=1-t;
clear_change1(t);
}
}
A: closegraph();
}