您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > 飞行棋游戏程序C语言代码
#includestdio.h#includewindows.h#includeconio.h#includestdlib.h#includetime.hvoidrestart(intmap[100]){intm[100]={100,0,0,0,0,2,1,0,0,3,0,0,0,2,0,0,0,2,0,0,4,0,0,1,0,4,0,3,0,0,0,0,0,2,0,0,0,0,2,0,1,0,0,0,0,4,0,0,0,0,2,0,0,0,0,1,0,0,0,0,3,0,0,4,2,0,0,0,0,1,0,0,4,0,0,0,0,0,0,0,2,0,0,1,0,0,0,0,4,0,4,0,0,3,2,0,0,0,0,0};/*这里是地图代码*/inti;FILE*fp=fopen(map.txt,r);if(fp!=0){printf(找到地图。尝试加载地图……);for(i=0;i100;i++){fscanf(fp,%d,&map[i]);if(map[i]!=0&&map[i]!=1&&map[i]!=2&&map[i]!=3&&map[i]!=4&&map[i]!=10&&map[i]!=20&&map[i]!=100){map[i]=m[i];}}fclose(fp);}else{printf(未找到地图。加载默认地图中……);for(i=0;i100;i++)map[i]=m[i];}printf(地图加载完成);Sleep(500);}/*用来给map数组赋值*//*用来输出游戏规则*//*用来输出地图*/voidprintmap(intmap[]){inti=0,j=1;printf('∷'是平地,'¤'是幸运罗盘,'★'是地雷,'■'是暂停,'〓'是时空隧道\n);printf(\n);for(i=0;i31;i++){switch(map[i]){case0:printf(∷);break;case1:printf(¤);break;case2:printf(★);break;case3:printf(■);break;case4:printf(〓);break;case10:printf(A);break;case20:printf(B);break;case100:printf(@@);break;}}printf(\n);for(;i35;i++){switch(map[i]){case0:printf(∷\n);break;case1:printf(¤\n);break;case2:printf(★\n);break;case3:printf(■\n);break;case4:printf(〓\n);break;case10:printf(A\n);break;case20:printf(B\n);break;}}for(;i66;i++){switch(map[66-(j++)]){case0:printf(∷);break;case1:printf(¤);break;case2:printf(★);break;case3:printf(■);break;case4:printf(〓);break;case10:printf(A);break;case20:printf(B);break;}}printf(\n);for(;i69;i++){switch(map[i]){case0:printf(∷\n);break;case1:printf(¤\n);break;case2:printf(★\n);break;case3:printf(■\n);break;case4:printf(〓\n);break;case10:printf(A\n);break;case20:printf(B\n);break;}}for(;i100;i++){switch(map[i]){case0:printf(∷);break;case1:printf(¤);break;case2:printf(★);break;case3:printf(■);break;case4:printf(〓);break;case10:printf(A);break;case20:printf(B);break;case100:printf(@@);break;}}printf(\n);printf(\n);}/*用来输出地图*//*拟定双人游戏规则及产生走路动画*/int_flash(intmap[],intss,int*pl,int*pl2,intwhatplayer){inti,t;time_tnow,d;charc;printf(%d!,ss);Sleep(100);if(whatplayer==1){for(i=0;i100;i++){if(map[i]==10){map[i]=0;break;}}for(i=1;i=ss;i++){system(cls);printmap(map);if(*pl+ss=99||*pl2+ss=99){if(*pl+ss=99){*pl=99;return0;}elseif(*pl2+ss=99){*pl2=99;return0;}}t=map[*pl+i];map[*pl+i]=10;Sleep(100);system(cls);printmap(map);Sleep(100);map[*pl+i]=t;}Sleep(50);system(cls);*pl=*pl+ss;if(map[*pl]==1){printf(恭喜来到幸运罗盘!\n);printf(请做出选择:\n);printf(按1.和对方骑兵交换位置按2.轰炸对方骑兵(炸退六步)按其他键:还是算了\n);c=getch();switch(c){case'1':printf(嗖嗖嗖............\n);Sleep(500);printf(B:\???怎么回事??\\n);Sleep(300);t=*pl;*pl=*pl2;*pl2=t;system(cls);Sleep(50);break;case'2':printf(A:\炸弹归来......\\n);Sleep(500);printf(B:\哎呦喂!\\n);Sleep(300);map[*pl2]=0;*pl2=*pl2-6;if(map[*pl]==map[*pl2]){Sleep(300);printf(B:\:-D哈哈哈哈...踩到了!\\n);Sleep(800);map[0]=20;map[*pl]=0;*pl=0;system(cls);}if(*pl20)*pl2=0;system(cls);Sleep(50);break;}}elseif(map[*pl]==2){Sleep(300);printf(A:\~~:-(踩到地雷,气死了......\\n);Sleep(50);Sleep(300);map[*pl]=0;*pl=*pl-6;if(map[*pl]==map[*pl2]){Sleep(300);printf(A:\:-D哈哈哈哈...踩到了!\\n);Sleep(800);map[0]=20;map[*pl2]=0;*pl2=0;system(cls);}if(*pl0)*pl=0;system(cls);}elseif(map[*pl]==3){printf(~~_~~要停战一局了。);Sleep(1750);if(*pl=99||*pl2=99){if(*pl=99){*pl=99;return0;}elseif(*pl2=99){*pl2=99;return0;}}system(cls);printmap(map);printf(请玩家2按任意键投掷骰子:\n);d=getch();if(*pl=99||*pl2=99){if(*pl=99){*pl=99;return0;}elseif(*pl2=99){*pl2=99;return0;}}printf(丁零当啷......);Sleep(1000);now=time(NULL);d+=now;while(d3)d=d/(rand()%5+1);_flash(map,d+1+rand()%2,pl,pl2,2);system(cls);}elseif(map[*pl]==4){Sleep(300);printf(A:\|-p进入时空隧道,真爽!\\n);Sleep(50);Sleep(1000);map[*pl]=0;*pl=*pl+10;if(*pl99)*pl=99;system(cls);}elseif(map[*pl]==map[*pl2]){Sleep(300);printf(A:\:-D哈哈哈哈...踩到了!\\n);Sleep(800);map[0]=20;map[*pl2]=0;*pl2=0;system(cls);}map[*pl]=10;map[*pl2]=20;printmap(map);}else{for(i=0;i100;i++){if(map[i]==20){map[i]=0;break;}}for(i=1;i=ss;i++){system(cls);printmap(map);if(*pl=99||*pl2=99){if(*pl=99)return0;}elseif(*pl2=99){*pl2=99;return0;}}t=map[*pl2+i];map[*pl2+i]=20;Sleep(100);system(cls);printmap(map);Sleep(100);map[*pl2+i]=t;}system(cls);*pl2=*pl2+ss;if(map[*pl2]==1){printf(恭喜来到幸运罗盘!\n);printf(请做出选择:\n);printf(按1.和对方骑兵交换位置按2.轰炸对方骑兵(炸退六步)按其他键:还是算了\n);c=getch();switch(c){case'1':printf(嗖嗖嗖............\n);Sleep(500);printf(A:\???怎么回事??\\n);Sleep(300);t=*pl;*pl=*pl2;*pl2=t;system(cls);Sleep(50);break;case'2':printf(B:\炸弹归来......\\n);Sleep(500);printf(A:\哎呦喂!\\n);Sleep(300);map[*pl]=0;*pl=*pl-6;if(map[*pl]==map[*pl2]){Sleep(300);printf(A:\:-D哈哈哈哈...踩到了!\\n);Sleep(800);map[0]=20;map[*pl2]=0;*pl2=0;system(cls);}if(*pl0)*pl=0;system(cls);Sleep(50);break;}}elseif(map[*pl2]==2){Sleep(300);printf(B:\~~:-(踩到地雷,气死了......\\n);Sleep(50);Sleep(300);map[*pl2]=0;*pl2=*pl2-6;if(map[*pl]==map[*pl2]){Sleep(300);printf(B:\:-D哈哈哈哈...踩到了!\\n);Sleep(300);map[0]=10;map[*pl]=0;*pl=0;}if(*pl20)*pl2=0;system(cls);}elseif(map[*pl2]==3){printf(~~_~~要停战一局了。);Sleep(1750);if(*pl=99||*pl2=99){if(*pl=99){*pl=99;return0;}elseif(*pl2=99){*pl2=99;return0;}}system(cls);printmap(map);printf(请
本文标题:飞行棋游戏程序C语言代码
链接地址:https://www.777doc.com/doc-3917389 .html