五子棋代码c语言easyx库,五子棋源代码

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

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();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值