




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
//////////////////////////////mainO
#include<stdio.h>
//#include<afx.h>
#include<string.h>
#inc1ude<windows.h>//gotoXY,sleep;
#include<conio.h>//kbhit();
#include<stdlib.h>//exit(1);
#include<time.h>
#include,/statement.h〃
ttinclude^function.h〃
intmainO
{
fpscore=fopen(,zhighestscore.dat","r〃);
fgets(HighestScoreName,30,fpscore);
fscanf(fpscore,"%d”,&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=l;
scorejudge=0;
break;
return0;
頭文件function
voidfunProduceFood()
(
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==O&&maparr[njudge1][njudge2]!='*')
maparr[njudgel][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(GetStdIIandle(STD_OUTPUT_HAN
DLE),coord);
return;
voidfunprintf()
if(score%100==0&&score!=0&&score!=scorejudge)
Grade++;
scorejudge=score;
}
for(intnk=O;nk<Ik;nk++)
printf("%2c',';
printf('AtScore:%d-Grade:%d\n|score,Grade);
if(Grade!=spee&&speed!=l)
(
speed=(speed-(Grade*(990000)));
spee++;
}
for(intni=0;ni<Ik;ni++)
(
for(intnt=0;nt<Ik;nt++)
printfmaparr[ni][nt]);
//if(ni==12ni==13)
//{
//if(ni==12)
//printfCI\t英?雄?
毗%s)",HighestScoreName);
//if(ni==13)
//printfClXt最?高?分?
毗%d\n|nhighestscore);
//)
//else
printf("[\n|");
}
printf("\b〃);
for(intnk=O;nk<Ik;nk++)
printf("%2c",'?');
gotoXY(57,12);
printf("英?雄?:HighestScoreName);
gotoXY(57,13);
printf("最?高?分?:nhighestscore);
)
intfundirection(intni,intnj)
switch(direction)
case2:
case0:
if(ni<judgel)
(
direction=l;
return(judgel-ni);
}
if(ni>judgel)
(
direction=3;
return(ni-judgel);
}
break;
case3:
case1:
if(nj<judge2)
(
direction=0;
return(judge2-nj);
if(nj>judge2)
direction=2;
return(nj-judge2);
}
}
)
voidfunoperation」()
{
maparr[I][J]=,;
funProduceFood();
if(np==495)
np=-l;
if(npl==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!=1)
spe=speed;
speed=l;
speedjudge=l;
)
elseif(speedjudge==l)
speed=spe;
speedjudge=O;
}
direction=3;
break;
case'4':
case75:
if(direction==2)
{
if(speed!=l)
spe=speed;
speed=l;
speedjudge=l;
elseif(speedjudge==l)
(
speed=spe;
speedjudge=O;
}
direction^;
break;
case'5':
case80:
case'2,:
if(direction==l)
(
if(speed!=l)
spe=speed;
speed=l;
speedjudge=l;
}
elseif(speedjudge==l)
{
speed=spe;
speedjudge=0;
}
direction=l;
break;
case'6':
case77:
if(direction==0)
if(speed!=l)
spe=speed;
speed=l;
speedjudge=l;
)
elseif(speedjudge==l)
{
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;〃從洙?鍵U盤(pán)i上?讀G取?方?向6
switch(direction)
(
case0:
maparr[I][J]=,*,;
if(J==(Ik-l))
J=-l;
if(maparr[I][++J]==,$')
{
npl一;
score+=10;
if(maparr[I][J]==,*,)
gotoXY(57,6);
if(score>nhighestscore)
{
nhighestscore=score;
printf(〃?!瓯疲??破?紀(jì)i錄?了?!?〃);
gotoXY(57,7);
printf(〃英?雄?,?留?下?名?字?:毗〃);
scanfHighestScoreName);
fpscore=fopen(,zhighestscore.dat","w");
fprintf(fpscore,"%s\n”,HighestScoreName);
fprintf(fpscore,"%d〃,nhighestscore);
fclose(fpscore);
gotoXY(57,8);
printf("playagainpressenterorpress5!!”);
I
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;
)
else
exit(1);
}
exit(1);
}
funoperationl();
break;
case1:
maparr[I][J]='*';
if(I==(Ik-l))
I=-l;
if(maparr[++I][J]==,$')
(
npl一;
score+=10;
}
if(maparr[I][J]==,*,)
(
gotoXY(57,6);
if(score>nhighestscore)
{
nhighestscore=score;
printf(〃牛£逼?,?破?紀(jì)i錄?了?!?〃);
gotoXY(57,7);
printf(〃英?雄?,?留?下?名?字?:毗〃);
scanfHighestScoreName);
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;
)
else
exit(1);
)
exit(1);
}
funoperation」();
break;
case2:
maparr[I][J]=,*,;
if(J==0)
J=Ik;
if(maparr[I][—J]=-$')
(
gotoXY(0,0);
npl一;
score+=10;
}
if(maparr[[][曰==,*,)
{
gotoXY(57,6);
if(score>nhighestscore)
{
nhighestscore=score;
printf(〃?!瓯??,?破?紀(jì)i錄?了?!?〃);
gotoXY(57,7);
printf(〃英?雄?,?留?下?名?字?:毗“);
scanfHighestScoreName);
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;
)
else
exit(1);
}
exit(1);
}
funoperation_l();
break;
case3:
maparr[I][J]=,*,;
if(1=0)
I=Ik;
if(maparr[—I][J]==,$')
npl—;
score+=10;
}
if(maparr[I][J]==,*,)
(
gotoXY(57,6);
if(score>nhighestscore)
{
nhighestscore=score;
printf(〃牛£逼?,?破?紀(jì)i錄?了????〃);
gotoXY(57,7);
printf(〃英?雄?,?留?下?名?字?:毗〃);
scanfHighestScoreName);
fpscore=fopen(z,highestscore.dat〃,"w");
fprintf(fpscore,"%s\n",HighestScoreName);
fprintf(fpscore,nhighestscore);
fclose(fpscore);
gotoXY(57,8);
printfC'playagainpressenterorpr
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年臥式離子風(fēng)機(jī)項(xiàng)目資金申請(qǐng)報(bào)告代可行性研究報(bào)告
- 2025年廣西安全工程職業(yè)技術(shù)學(xué)院?jiǎn)握新殬I(yè)技能測(cè)試題庫(kù)帶答案
- 2025屆河北省廊坊市高三上學(xué)期期末英語(yǔ)試題及答案
- 2025年度建筑改造項(xiàng)目承重墻拆除安全責(zé)任免責(zé)協(xié)議
- 2025年度拆除施工與建筑垃圾回收合同
- 2025年度電力設(shè)施安全保證金合同
- 2025年度廢輪胎回收與橡膠顆粒生產(chǎn)合同
- 2025年度房地產(chǎn)銷售代理與服務(wù)合同
- 2025年度醫(yī)療機(jī)構(gòu)與保險(xiǎn)公司合作康復(fù)服務(wù)協(xié)議
- 2025年度工業(yè)廠房轉(zhuǎn)租租賃合同
- 《市場(chǎng)營(yíng)銷學(xué)》講稿
- 2025年中國(guó)陪診服務(wù)行業(yè)現(xiàn)狀、發(fā)展環(huán)境及投資前景分析報(bào)告
- 靜脈治療相關(guān)血管解剖結(jié)構(gòu)與生理
- 統(tǒng)編版九年級(jí)道德與法治上冊(cè)期中考試卷及答案
- 學(xué)校安全隱患報(bào)告和舉報(bào)獎(jiǎng)懲制度
- 福建師范大學(xué)《廣告作品賞析》2022-2023學(xué)年第一學(xué)期期末試卷
- 對(duì)外經(jīng)貿(mào)-會(huì)計(jì)學(xué)原理考試答案
- 消渴病中醫(yī)護(hù)理
- 大學(xué)生職業(yè)素養(yǎng)訓(xùn)練(第六版)課件 第五單元學(xué)會(huì)有效溝通
- 醫(yī)院醫(yī)療項(xiàng)目收費(fèi)管理制度
- 建筑師負(fù)責(zé)制工程建設(shè)項(xiàng)目建筑師標(biāo)準(zhǔn)服務(wù)內(nèi)容與流程
評(píng)論
0/150
提交評(píng)論