资源描述:
《C语言游戏之五子棋源代码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、C语言游戏之五子棋源代码#include#include#include#include#include#defineLEFT0x4b00 #defineRIGHT0x4d00 #defineDOWN0x5000 #defineUP0x4800#defineESC0x011b #defineSPACE0x3920 #defineBILI20 #defineJZ4 #defineJS3 #defineN19 intbo
2、x[N][N];intstep_x,step_y;intkey;intflag=1;voiddraw_box();voiddraw_cicle(intx,inty,intcolor);voidchange();voidjudgewho(intx,inty);voidjudgekey();intjudgeresult(intx,inty);voidattentoin(); voidattention(){ charch; window(1,1,80,25); textbackground(LIGHTB
3、LUE); textcolor(YELLOW); clrscr(); gotoxy(15,2); printf("游戏操作规则:"); gotoxy(15,4); printf("PlayRules:"); gotoxy(15,6); printf("1、按左右上下方向键移动棋子"); gotoxy(15,8); printf("1.PressLeft,Right,Up,DownKeytomovePiece"); gotoxy(15,10); printf("2、
4、按空格确定落棋子"); gotoxy(15,12); printf("2.PressSpacetoplacethePiece"); gotoxy(15,14); printf("3、禁止在棋盘外按空格"); gotoxy(15,16); printf("3.DONOTpressSpaceoutsideofthechessboard"); gotoxy(15,18); printf("你是否接受上述的游戏规则(Y/N)"); gotoxy(15,20); printf("D
5、oyouaccepttheabovePlayingRules?[Y/N]:"); while(1) { gotoxy(60,20); ch=getche(); if(ch=='Y'
6、
7、ch=='y') break; elseif(ch=='N'
8、
9、ch=='n') { window(1,1,80,25); textbackground(BLACK); textcolor(LIGHTG
10、RAY); clrscr(); exit(0); } gotoxy(51,12); printf(""); }}voiddraw_box()5{ intx1,x2,y1,y2; setbkcolor(LIGHTBLUE); setcolor(YELLOW); gotoxy(7,2); printf("Left,Right,Up,DownKEYtomove,Spacetoput,ESC-quit."); for(x1=1,
11、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)*BILI,(x2+JZ)*BILI,(y1+JS)*BILI); for(x1=1;x1<=18;x1++) for(y1=1;y1<=18;y1++) box[x1][y1]=0;} voiddraw_ci
12、rcle(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: