版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
//////////////////////////////mainO#include<stdio.h>//#include<afx.h>#include<string.h>//gotoXY,sleep;//kbhit();//exit//gotoXY,sleep;//kbhit();//exit⑴;#include<conio.h>#include<stdlib.h>#include<time.h>#include/zstatement,h”#include/,function,h”intmain(){fpscore=fopen(^highestscore.dat","r");fgets(HighestScoreName,30,fpscore);fscanf(fpscore,&nhighestscore);fclose(fpscore);while(true)system("cis");//gotoXY(0,0);srand(time(NULL));funmapdefine(maparr,'');//funprintf();pchar[np]=&maparr[I][J];funProduceFood();while(true)]while((tim++)%speed==0)funoperation();if(again~l){again=0;speedjudge=0;tim=0;spe=0;speed=9999000;spee=l;direction=0;1=12;J=12;np=O;npl=O;score-0;Grade-1;scorejudge=O;break;return0;)头文件functionvoidfunProduceFood()intnjudge=0;intnjudgel=0;intnjudge2=0;for(inti=0;i<Ik;i++)for(intj=0;j<Ik;j++)if(maparr[i][j]=='$')njudge++;while(true){njudgel=rand()%Ik;njudge2=rand()%Ik;if(maparr[njudge1][njudge2]!='*')break;}if(njudge-0&&maparr[njudge1][njudge2]!='*'){maparr[njudge1][njudge2]='$';judgel=njudgel;judge2=njudge2;}}voidfunmapdefine(char[][24],charc){for(intn=0;n<Ik;n++)for(intt=0;t<Ik;t++)
maparr[n][t]=c;)voidgotoXY(intx,inty){COORDcoord={x,y};SetConsoleCursorPosition(GetStdHandle(STDOUTPUTHANDLE),coord);return;)voidfunprintf()if(score%100==0&&score!=0&&score!=scorejudge)Grade++;scorejudge=score;}for(intnk=0;nk<Ik;nk++)printf("%2c',' ;printf('\tScore:%d-Grade:%d\n;score,Grade);if(Grade!=spee&&speed!=l){speeds(speed-(Grade*(990000)));spee++;}for(intni=0;ni<Ik;ni++){for(intnt=0;nt<Ik;nt++)printf(,,%2c,,>maparr[ni][nt]);//if(ni==12||ni—13)//{//if(ni==12)//printfC|\t英 ?雄?毗%s|HighestScoreName);//if(ni==13)//printfC|\t最?高?分?:毗%d\n|nhighestscore);//)//elseprintf("[\nI");}printf('\b");for(intnk=0;nk<Ik;nk++)printf("%2c",'、');gotoXY(57,12);printf("英?雄?:毗%s”,HighestScoreName);gotoXY(57,13);printf("最?高?分?:毗%d”,nhighestscore);}intfundirection(intni,intnj)switch(direction)case0:if(ni<judgel)]directional;return(judgel-ni);)if(ni>judgel)direction=3;return(ni-judgel);)break;case1:if(nj<judge2)(direction=0;return(judge2-nj);if(nj>judge2)direction=2;return(nj-judge2);)})voidfunoperationl()(maparr[I][J]=,@';funProduceFood();if(np—495)np=~l;if(np1—496)npl=0;pchar[++np]=&maparr[I][J];if(np>nlength)*pchar[npl++]=,,;funprintf();gotoXY(0,0);//gotoXY(0,0);}voidfunkbhit(){if(kbhit())]charch=getch();switch(ch)]case'8’:case72:if(direction-3){if(speed!=l)spe=speed;speed=l;speedjudge=l;elseif(speedjudge-l)speed=spe;speedjudge-0;idirection=3;break;case'4':case75:if(direction--2)(if(speed!-l)spe=speed;speed=l;speedjudge-1;Ielseif(speedjudge==l)(speed=spe;speedjudge-0;Idirection=2;break;case'5':case80:case'2':if(direction—l){if(speed!=l)spe-speed;speed=l;speedjudge=l;)elseif(speedjudge--1)(speed-spe;speedjudge=0;}direction-1;break;case'6’:case77:if(direction"。){if(speed!=l)spe-speed;speed=l;speedjudge=l;}elseif(speedjudge-1)(speed=spe;speedjudge=O;}direction=0;break;case'':system("pause");gotoXY(0,0);default:break;)}elseif(speedjudge-l){speed=spe;speedjudge=0;voidfunoperation(){/*if(judge-0)judge=fundirection(I,J);judge―;*/funkbhitO;〃从洙?键口盘i上?读d取?方?向6switch(direction)]case0:maparr[I][J]='*';if(J==(Ik-l))J=T;if(maparr[I][++J]=- )]npl—;score+=10;if(maparr[I][J]~,*')gotoXY(57,6);if(score>nhighestscore)(nhighestscore=score;printf("牛£逼?,?破?纪i录?了?!?〃);gotoXY(57,7);printf(〃英?雄?,?留?下?名?字?:毗〃);scanf('%s”,HighestScoreName);fpscore=fopen(^highestscore.dat","w");fprintf(fpscore,"%s\n",HighestScoreName);fprintf(fpscore,"%d”,nhighestscore);fclose(fpscore);gotoXY(57,8);printf("playagainpressenterorpress5!!”);Ielse(gotoXY(57,6);printf("youarelost!?");gotoXY(57,7);printf(*playagainpressenterorpress5!!”);Sleep(2000);if(kbhit())charcyn;cyn=getch();if(cyn==13||cyn--,5,)(gotoXY(0,0);again=l;break;)elseexit(1);}exit(1);)funoperation1();break;maparr[I][J]=,*';I=-l;if(maparr[++I][J]==,$,)]npl一;score+=10;}if(maparr[I][J]=='*,)]gotoXY(57,6);if(score>nhighestscore)(nhighestscore=score;printf(〃牛£逼?,?破?纪i录?了?!?〃);gotoXY(57,7);printf(〃英?雄?,?留?下?名?字?:一”);scanf('%s”,HighestScoreName);fpscore=fopen(''highestscore.dat","w");fprintf(fpscore,"%s\n",HighestScoreName);fprintf(fpscore,"%d”,nhighestscore);fclose(fpscore);gotoXY(57,8);printf(z/playagainpressenterorpress5!!”);else(gotoXY(57,6);printf("youarelost!?");gotoXY(57,7);printf("playagainpressenterorpress5!!”);}Sleep(2000);if(kbhit())(charcyn;cyn=getch();if(cyn~131|cyn~,5,)]gotoXY(0,0);again=l;break;)elseexit(1);exit(1);)funoperationl();break;maparr[I][J]='*';if(J==0)J=Ik;if(maparr[I][—J]=- )]gotoXY(0,0);npl—;score+=lO;}if(maparr[I][J]==,*,)]gotoXY(57,6);if(score>nhighestscore)(nhighestscore=score;printf(〃牛£逼?,?破?纪i录?了?!?”);gotoXY(57,7);printf(〃英?雄?,?留?下?名?字?:一〃);scanf(,/%s,/,HighestScoreName);fpscore=fopen(^highestscore.dat","w");fprintf(fpscore,"%s\n",HighestScoreName);fprintf(fpscore,"%d”,nhighestscore);fclose(fpscore);gotoXY(57,8);printf("playagainpressenterorpress5!!”);}else(gotoXY(57,6);printf("youarelost!?");gotoXY(57,7);printf("playagainpressenterorpress5!!”);}Sleep(2000);if(kbhit())charcyn;cyn:getch();if(cyn==13||cyn=二'5")gotoXY(0,0);again=l;break;)elseexit(1);)exit(1);)funoperationl();break;maparr[I][J]二';if(I==0)I=Ik;if(maparr[―I][J]==,$')npl—;score+=10;}if(maparr[I][J]~,*')]gotoXY(57,6);if(score>nhighestscore)(nhighestscore=score;printf(〃牛£逼?,?破?纪i录?了?!?〃);gotoXY(57,7);printf(〃英?雄?,?留?下?名?字?:附〃);scanfHighestScoreName);fpscore=fopenC'highestscore.dat","w");fprintf(fpscore,"%s\n",HighestScoreName);fprintf(fpscore,"%d”,nhighestscore);fclose(fpscore);gotoXY(57,8);printf(/zplayagainpressenterorpress5!!”);elsegotoXY(57,6);printf(*youarelost!?");gotoXY(57,7);printf(*playagainpressenterorpress
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024-2030年中国生物接触氧化塔项目可行性研究报告
- 2024-2030年中国玻璃纤维行业竞争策略及发展潜力研究报告
- 2024-2030年中国玻尿酸钠行业供需趋势及投资风险研究报告
- 2024-2030年中国猴车行业发展趋势及竞争策略分析报告
- 2024-2030年中国照相器材行业竞争力策略及发展潜力分析报告
- 2024-2030年中国淋浴屏行业销售模式及未来发展规划分析报告
- 2024-2030年中国液化石油气罐车产业未来发展趋势及投资策略分析报告
- 2024-2030年中国液化气瓶除锈机产业未来发展趋势及投资策略分析报告
- 2024-2030年中国海藻糖行业市场调查分析及投资价值研究报告
- 2024-2030年中国汽车齿轮行业发展状况投资潜力研究报告
- GB/T 10001.1-2023公共信息图形符号第1部分:通用符号
- 海南省义务教育学校办学基本标准(试行)
- 卟啉病(改)课件
- 过程流程图专业知识讲座
- 民航M9英语词汇练习
- 处方书写规范-课件
- GB/T 12727-2023核电厂安全重要电气设备鉴定
- 部编版道德与法治六年级下册第二单元《爱护地球共同责任》大单元作业设计
- 2023年重庆移动招聘考试试题(附答案)
- 故障车辆应急调换方案
- 2023年中小学教师心理健康教育试卷(含答案)
评论
0/150
提交评论