




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 浙江育英職業(yè)技術(shù)學院《文學概論》2023-2024學年第一學期期末試卷
- 福建警察學院《軟件測試與維護》2023-2024學年第二學期期末試卷
- 惠州工程職業(yè)學院《古典詩詞鑒賞與吟誦》2023-2024學年第二學期期末試卷
- 寧德師范學院《科技寫作與科研素養(yǎng)》2023-2024學年第二學期期末試卷
- 保安證考試前瞻性試題及答案
- 保安證考試全面發(fā)展題及答案
- 四川省眉山市彭山區(qū)一中2025屆高三下學期期末質(zhì)量評估物理試題試卷含解析
- 2025屆三明市重點中學高三下學期第四次適應(yīng)性訓練英語試題含解析
- 江蘇省鹽城市亭湖區(qū)校聯(lián)考2024-2025學年九年級下學期3月月考語文試題(含答案)
- 15 2025年高中化學科學素養(yǎng)模擬試題及答案
- 2024年國家教育部學位與研究生教育發(fā)展中心招聘6人(非事業(yè)編制)歷年公開引進高層次人才和急需緊缺人才筆試參考題庫(共500題)答案詳解版
- 一年級下冊語文課件《2-我多想去看看》人教部編版-20
- 叉車高級工培訓課件
- TIAC 27-2019《機動車保險車聯(lián)網(wǎng)數(shù)據(jù)采集規(guī)范》
- 設(shè)備故障排除與處理方法
- 歌唱二小放牛郎 金巍 女聲合唱譜
- 平面構(gòu)成全套教學課件
- 創(chuàng)新素養(yǎng)的培養(yǎng)
- 南航禮儀培訓課件
- 江蘇省徐州市2023-2024學年七年級上學期期末語文試題
- 《動態(tài)血壓監(jiān)測》課件
評論
0/150
提交評論