资源描述:
《c语言程序源代码_五子棋游戏》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、/*五子棋*/#include#include#include#include#include#defineLEFT0x4b00#defineRIGHT0x4d00#defineDOWN0x5000#defineUP0x4800#defineESC0x011b#defineSPACE0x3920#defineBILI20#defineJZ4#defineJS3#defineN19intbox[N][N];intstep_x,step_y;intkey;intflag=1;voiddra
2、w_box();voiddraw_cicle(intx,inty,intcolor);voidchange();voidjudgewho(intx,inty);voidjudgekey();intjudgeresult(intx,inty);voidattentoin();voidattention(){charch;window(1,1,80,25);textbackground(LIGHTBLUE);textcolor(YELLOW);clrscr();gotoxy(15,2);printf("游戏操作规则:");gotoxy(15,4);printf("PlayRules:
3、");gotoxy(15,6);printf("1、按左右上下方向键移动棋子");gotoxy(15,8);printf("1.PressLeft,Right,Up,DownKeytomovePiece");gotoxy(15,10);printf("2、按空格确定落棋子");gotoxy(15,12);printf("2.PressSpacetoplacethePiece");gotoxy(15,14);printf("3、禁止在棋盘外按空格");gotoxy(15,16);printf("3.DONOTpressSpaceoutsideofthechessboard");go
4、toxy(15,18);printf("你是否接受上述的游戏规则(Y/N)");gotoxy(15,20);printf("DoyouaccepttheabovePlayingRules?[Y/N]:");while(1){gotoxy(60,20);ch=getche();if(ch=='Y'
5、
6、ch=='y')break;elseif(ch=='N'
7、
8、ch=='n'){window(1,1,80,25);textbackground(BLACK);textcolor(LIGHTGRAY);clrscr();exit(0);}gotoxy(51,12);printf("");
9、}}voiddraw_box(){intx1,x2,y1,y2;setbkcolor(LIGHTBLUE);setcolor(YELLOW);gotoxy(7,2);printf("Left,Right,Up,DownKEYtomove,Spacetoput,ESC-quit.");for(x1=1,y1=1,y2=18;x1<=18;x1++)line((x1+JZ)*BILI,(y1+JS)*BILI,(x1+JZ)*BILI,(y2+JS)*BILI);for(x1=1,y1=1,x2=18;y1<=18;y1++)line((x1+JZ)*BILI,(y1+JS)*BIL
10、I,(x2+JZ)*BILI,(y1+JS)*BILI);for(x1=1;x1<=18;x1++)for(y1=1;y1<=18;y1++)box[x1][y1]=0;}voiddraw_circle(intx,inty,intcolor){setcolor(color);setlinestyle(SOLID_LINE,0,1);x=(x+JZ)*BILI;y=(y+JS)*BILI;circle(x,y,8);}voidjudgekey(){inti;intj;switch(key){caseLEFT:if(step_x-1<0)break;else{for(i=step_x
11、-1,j=step_y;i>=1;i--)if(box[i][j]==0){draw_circle(step_x,step_y,LIGHTBLUE);break;}if(i<1)break;step_x=i;judgewho(step_x,step_y);break;}caseRIGHT:if(step_x+1>18)break;else{for(i=step_x+1,j=step_y;i<=18;i++)if(box[i][j]==0){draw_circle(step_x,s