版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、#include<graphics.h> #include<conio.h> #include<string.h> #include<bios.h> #include<stdlib.h> #include"c:tcLIB1.c"#define W 119 #define S 115 #define A 97 #define D 100 #define space 32#define UP 72 #define DOWN 80 #define LEFT 75 #define RIGHT 77 #define ENTE
2、R 13 void qipan();void jiemian(int);void guangbiao1(int,int);void guangbiao2(int,int);void xuanzhong(int,int);void gaizi(int,int);char array(int,int);void xiazi(int,int,int,int);/*int panding(char,int,int,int,int);*/ main()int gdriver,gmode,i=0,c=0,x=190,y=190,m,n;char p;FILE *fp;gdriver=DETECT;gmod
3、e=0;if(fp=fopen("file.txt","at") = NULL)printf("Cannot open file!");system("pause");exit(0);printf("%d,%d",gdriver,gmode);registerbgidriver(EGAVGA_driver);initgraph(&gdriver,&gmode,"c:tc");cleardevice();while(c!=27)c=getch();clrscr(
4、);jiemian(i);if(c=80)fputs("down ",fp);i+;if(i=4)i=0;if(i=1)if(c=13)fputs("enter ",fp);qipan();c=getch();while(c!=27)c=getch();if(c=115)fputs("S ",fp);y=y+40;guangbiao1(x,y);guangbiao2(x,y-40);if(c=119)fputs("W ",fp);guangbiao1(x,y);guangbiao2(x,y+40);y=y-40;i
5、f(c=97) fputs("An",fp);x=x-40;guangbiao1(x,y);guangbiao2(x+40,y);if(c=100) fputs("Dn",fp);x=x+40;guangbiao1(x,y);guangbiao2(x-40,y);if(c=13)fputs("entern",fp);xuanzhong(x,y);m=x;n=y;fputs("spacen",fp);xiazi(m,n,x,y);if(c=32)fputs("gaizin",fp);gaizi(m
6、,n);if(x>350|y>390|x<30|y<30) x=190;y=30;getch();closegraph();fclose(fp);restorecrtmode();return 0;void qipan() int i,j;setbkcolor(GREEN);cleardevice();setlinestyle(0,0,3);setcolor(1);rectangle(10,10,370,410);rectangle(30,30,350,390);for(i=1;i<8;i+)setlinestyle(0,0,3);line(i*40+30,30,
7、i*40+30,190);line(i*40+30,230,i*40+30,390);for( j=1;j<9;j+)setlinestyle(0,0,3);line(30,j*40+30,350,j*40+30);setlinestyle(3,0,3);line(150,30,230,110);line(150,310,230,390);line(230,310,150,390);setusercharsize(4,1,2,1);line(230,30,150,110);settextstyle(1,0,4);chess");outtextxy(70,195,"ch
8、inesered_shuai(190,30);red_shi(150,30);red_shi(230,30);red_xiang(110,30);red_xiang(270,30);red_ma(70,30);red_ma(310,30);red_ju(30,30);red_ju(350,30);red_pao(70,110);red_pao(310,110);red_bing(30,150);red_bing(110,150);red_bing(190,150);red_bing(270,150);red_bing(350,150);black_jiang(190,390);black_sh
9、i(150,390);black_shi(230,390);black_xiang(110,390);black_xiang(270,390);black_ma(70,390);black_ma(310,390);black_ju(30,390);black_ju(350,390);black_pao(70,310);black_pao(310,310);black_zu(30,270);black_zu(110,270);black_zu(190,270);black_zu(270,270);black_zu(350,270);setcolor(BLUE);rectangle(400,30,
10、600,320);setcolor(4);settextstyle(1,0,2);outtextxy(420,50,"A->shuai B->shi");outtextxy(420,80,"C->xiang D->ma");outtextxy(420,110,"E->ju F->pao");outtextxy(420,140,"G->bing");setcolor(8);outtextxy(420,200,"H->jiang I->shi")
11、;outtextxy(420,230,"J->xiang K->ma");outtextxy(420,260,"L->ju M->pao");outtextxy(420,290,"N->zu");void jiemian(int i)setbkcolor(GREEN);cleardevice();settextstyle(1,0,8);setcolor(BLUE);outtextxy(50,70,"chinese chess");settextstyle(0,0,3);setcolor
12、(RED);outtextxy(260,215,"start");outtextxy(260,255,"again");outtextxy(260,295,"undo");outtextxy(260,335,"exit");rectangle(250,210+i*40,390,240+i*40);void guangbiao1(int x,int y)setcolor(WHITE);setlinestyle(0,0,3);line(x-17,y-7,x-17,y-17);line(x-7,y-17,x-17,y-1
13、7);line(x+7,y-17,x+17,y-17);line(x+17,y-7,x+17,y-17);line(x-7,y+17,x-17,y+17);line(x-17,y+7,x-17,y+17);line(x+17,y+7,x+17,y+17);line(x+7,y+17,x+17,y+17);void guangbiao2(int x,int y)setcolor(GREEN);setlinestyle(0,0,3);line(x-17,y-7,x-17,y-17);line(x-7,y-17,x-17,y-17);line(x+7,y-17,x+17,y-17);line(x+1
14、7,y+7,x+17,y+17);line(x+17,y-7,x+17,y-17);line(x-7,y+17,x-17,y+17);line(x-17,y+7,x-17,y+17);line(x+7,y+17,x+17,y+17);void xuanzhong(int x,int y)setcolor(CYAN);setlinestyle(0,0,3);circle(x,y,15);void gaizi(int x1,int y1)setlinestyle(0,0,3);setcolor(GREEN);circle(x1,y1,15);setfillstyle(0,3);floodfill(
15、x1,y1,GREEN);setcolor(1);setlinestyle(0,0,3);if(30<x1<350)&&(y1=30)|(y1=230)line(x1,y1,x1,y1+18);line(x1-18,y1,x1+18,y1);if(30<x1<350)&&(y1=390|y1=190)line(x1-18,y1,x1+18,y1);line(x1,y1-18,x1,y1);if(30<y1<390)&&x1=30)line(x1,y1,x1+18,y1);line(x1,y1-18,x1,y1+
16、18);if(30<y1<390)&&(x1=350)line(x1-18,y1,x1,y1);line(x1,y1-18,x1,y1+18);if(x1=30)&&(y1=30)line(x1,y1,x1+18,y1);line(x1,y1,x1,y1+18);if(x1=350)&&(y1=30)line(x1-18,y1,x1,y1);line(x1,y1,x1,y1+18);if(x1=30)&&(y1=390)line(x1,y1,x1+18,y1);line(x1,y1,x1,y1-18);if(x1=35
17、0)&&(y1=390)line(x1,y1,x1-18,y1);line(x1,y1,x1,y1-18);elseline(x1-18,y1,x1+18,y1);char array(int i,int j)line(x1,y1-18,x1,y1+18);char a1313;int c,b;c=i;b=j;for(c=1;c<10;c+)for(b=1;b<11;b+) acb='Z'a15='A'a14='B'a16='B'a13='C'a17='C'a12=
18、9;D'a18='D'a11 ='E'a19='E'a32='F'a38='F'a41=a43=a45=a47=a49='G'a105='H'a104='I'a106='I'a103='J'a107='J'a102='K'a108='K'a101='L'a109='L'a23='M'a83='M'a71=a73=a75
19、=a77=a79='N'return ai j;void xiazi(int x6,int y6,int x7,int y7)switch(array(y6/40+1,x6/40+1)case 'A':red_shuai(x7,y7);break;case 'B':red_shi(x6,y7);break;case 'C':red_xiang(x7,y7);break;case 'D':red_ma(x7,y7);break;case 'E':red_ju(x7,y7);break;case
20、9;F':red_pao(x7,y7);break;case 'G':red_bing(x7,y7);break;case 'H':black_jiang(x7,y7);/*break;case 'I':black_shi(x7,y7);break;case 'J':black_xiang(x7,y7);break;case 'K':black_ma(x7,y7);break;case 'L':black_ju(x7,y7);break;case 'M':black_pao(
21、x7,y7);break;case 'N':black_zu(x7,y7);break;case 'Z':gaizi(x6,x6);break;int panding(char q,int x,int y,int a,int b)switch(q)case 'A':if(y>110|x>230|x<150|(a-x)>40|(x-a)>40|(y-b)>40|(b-y)>40)return 0;elsereturn 1;break;case 'B':if(x-a)=40&&
22、(y-b)=40)&&y<=110&&230<x<150|(a-x)=40&&(b-y)=4 0)&&y<=110&&230>x>150)return 1;elsereturn 0;break;case 'C':if(x-a)=80&&(y-b)=80)&&y<=190)&&(array(y+b)/2/40+1,(x+a)/2/40+1,) ='Z')|(a-x)=80&&(b-
23、y)=80)&&y<=190)&&(array(y+b)/2/40+1,(x+a)/2/40 +1)='Z')else break;return 1;return 23;case 'D':if(x-a)=80&&(y-b)=40&&(array(y/40+1,(x-40)/40+1)='Z')|(a-x)=80& &(b-y)=40)&&(array(y/40+1,(x+40)/40+1)='Z')|(x-a)=40&&a
24、mp;(y-b)=80)(arra y(y-40)/40+1,x/40+1)='Z')|(a-x)=40&&(b-y)=80)&&(array(y+40)/40+1,x/4 0+1)='z ')return 1;elsereturn 0;break;case 'E':return 1;break;case 'F':return 1;break;case 'G':if(y<190)if(y>b|x!=a)return 0;elsereturn 2;elseif(b-y)&g
25、t;40|(a-x)>40|(x-a)>40|y>b)return 0;elsereturn 1;break;case 'H':if(y<310|x>230|x<150|(a-x)>40|(x-a)>40|(y-b)>40|(b-y)>40)return 0;elsereturn 1;break;case'I':if(x-a)=40&&(y-b)=40)&&y>=310&&230<x<150|(a-x)=40&&(b-y)=40)&&y>310&&230>x>150)return
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年德州职业技术学院高职单招职业适应性考试备考题库有答案解析
- 医疗行业服务礼仪与员工培训
- 2026年常州工程职业技术学院单招综合素质笔试备考试题带答案解析
- 新时代护理人才培养创新探索
- 口腔护理技术与口腔疾病预防
- 皮肤性病诊疗规范解析
- 医疗保险市场发展与监管
- 护理专业教育发展趋势
- 医院儿科礼仪与患儿沟通
- 2026年河源职业技术学院高职单招职业适应性考试备考题库带答案解析
- 2025年宁波市数据局直属事业单位公开招聘工作人员笔试历年典型考题(历年真题考点)解题思路附带答案详解
- 2025秋苏少版七年级上册美术期末测试卷(三套)
- 高校科研经费存在问题及对策建议
- (2024年)幼师必备幼儿园安全教育PPT《交通安全》
- 缩水机安全操作规程
- 颅内压波形分析
- 中国消化内镜内痔诊疗指南及操作共识(2023年)
- 2023年高校教师资格证之高等教育学真题及答案
- dosm新人落地训练全流程课程第五步三次面谈
- JJF 1798-2020隔声测量室校准规范
- 石湖矿综采放顶煤可行性技术论证1
评论
0/150
提交评论