纯C语言写的一个小型游戏 源代码文档格式.docx

上传人:b****6 文档编号:17335993 上传时间:2022-12-01 格式:DOCX 页数:21 大小:19.71KB
下载 相关 举报
纯C语言写的一个小型游戏 源代码文档格式.docx_第1页
第1页 / 共21页
纯C语言写的一个小型游戏 源代码文档格式.docx_第2页
第2页 / 共21页
纯C语言写的一个小型游戏 源代码文档格式.docx_第3页
第3页 / 共21页
纯C语言写的一个小型游戏 源代码文档格式.docx_第4页
第4页 / 共21页
纯C语言写的一个小型游戏 源代码文档格式.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

纯C语言写的一个小型游戏 源代码文档格式.docx

《纯C语言写的一个小型游戏 源代码文档格式.docx》由会员分享,可在线阅读,更多相关《纯C语言写的一个小型游戏 源代码文档格式.docx(21页珍藏版)》请在冰豆网上搜索。

纯C语言写的一个小型游戏 源代码文档格式.docx

intlocation[2];

structmap/*thisisthemapstructure*/

chardata[20];

charadd_data[20];

intamount;

intx;

/*thiswerethesuccessorkeepsit'

sx&

yvalues*/

inty;

structlocation/*thisstructureisforthesuccessorlister*/

floatheight;

charobj;

voidstats_update(intselected,structrover*p_rover)

switch(selected)

case1:

if(p_rover->

pwr<

7)

printf("

\n\nYoudonothaveenoughpowertoperformthisaction!

\n\n"

);

else

(p_rover->

pwr)-=7;

Youhavedestroyedtheobject!

}

break;

case2:

3)

elseif(p_rover->

strg>

90)

\n\nYoudonothaveenoughstoragespaceforthisobject!

pwr)-=3;

strg)+=10;

Youhavecollectedasampleoftheobject!

case3:

p_rover->

pwr-=10;

/*Distancearoundobject-valuegainedfrommappermodule.1square=-1power*/

Youhaveavoidedtheobject!

case4:

pwr-=2;

Youhavedriventhroughtheobstacle!

case5:

pwr==100)

\n\nYoudonotneedtochargeup!

pwr=100;

Youhavechargedupyourrover!

default:

\n\n*****ERROR*****\nInvalidSelection\n\n"

voidaction(charobject,structrover*p_rover)

intselection;

switch(object)

\nYouhaveencountered:

ASandyRock\n\n"

Thisobjectcanbe:

\n1.\tDestroyed\n2.\tCollected\nPleasechooseaction1or2:

\t"

scanf("

%d"

&

selection);

stats_update(selection,p_rover);

ASolidRock\n\n"

\n1.\tAvoided\n2.\tCollected\nPleasechooseaction1or2:

if(selection==1)

selection=3;

AMountain\n\n"

\n1.\tAvoided\nPleaseenter1:

Dust\n\n"

\n1.\tDriventhrough\n2.\tCollected\nPleasechooseaction1or2:

selection=4;

ASheerValley\n\n"

case6:

AGentleValley\n\n"

\n1.\tDriventhrough\n2.\tAvoided\nPleasechooseaction1or2:

if(selection==2)

case7:

A'

Martian'

Tree\n\n"

\n1.\tDestroyed\n2.\tCollected\n3.\tAvoided\nPleasechooseaction1,2or3:

case8:

ShallowWater\n\n"

\n1.\tDriventhrough\n2.\tCollected\n3.\tAvoided\nPleasechooseaction1,2or3:

case9:

DeepWater\n\n"

case10:

AnAggressiveAlien\n\n"

\n1.\tDestroyed\nPleaseenter1:

selection=1;

case11:

ANon-AggressiveAlien\n\n"

case12:

AnotherRover\n\n"

case13:

APowerStation\n\n"

Youcan:

\n1.\tChargeup\n2.\tAvoid\nPleasechooseaction1or2:

selection=5;

\n\n*****ERROR*****\n\n"

voidshow_map(structmap*number,structmap*number_2,structobject_fix*rsny,

structobject_fix*rsld,structobject_fix*mnt,structobject_fix*dst,

structobject_fix*vshr,structobject_fix*vgnt,structobject_fix*mtre,

structobject_fix*wshl,structobject_fix*wdp,structobject_move*aagr,

structobject_move*anon,structobject_move*rvr,structobject_move*pstn,structrover*p_rover)/*theshowmapfunctioncallingnumberandnumber_2fromthemapstructuretoseeifmoveableobjectsareneeded*/

structmapf_map[8][8];

/*8by8map*/

inti,j,rx,ry,object;

/*thisisyourxandyvalueinyourmap(f_map)*/

system("

cls"

/*thisisyourxandyvalueinyourmap(f_map)*/

//srand(time(NULL));

/*callingthetimefromincludetogatherrandomvariables*/

for(i=0;

i<

8;

i++)/*forlooptocopyallyourfixedobjectlistsintof_mapsotheycanbedisplayed*/

for(j=0;

j<

j++)

strcpy(f_map[i][j].data,"

"

if(number->

amount>

0)/*thisislookingattheaddfunctiontoseeweatherornottherearealiensinf_map*/

number->

amount;

i++)/*allocatingthenumberofaliensinf_map*/

strcpy(f_map[rand()%8][rand()%8].data,anon->

im);

/*randomizingtheirposition*/

if(number_2->

0)/*repeatofabovejustforroversinstead*/

number_2->

i++)

strcpy(f_map[rand()%8][rand()%8].data,rvr->

rx=p_rover->

location[0];

ry=p_rover->

location[1];

strcpy(f_map[1][0].data,wdp->

strcpy(f_map[4][0].data,mnt->

strcpy(f_map[5][0].data,mnt->

strcpy(f_map[3][1].data,dst->

strcpy(f_map[4][1].data,dst->

strcpy(f_map[3][2].data,dst->

strcpy(f_map[4][2].data,dst->

strcpy(f_map[0][3].data,mnt->

strcpy(f_map[1][3].data,mnt->

strcpy(f_map[3][3].data,vshr->

strcpy(f_map[4][3].data,dst->

strcpy(f_map[5][3].data,vgnt->

strcpy(f_map[3][4].data,vshr->

strcpy(f_map[4][4].data,dst->

strcpy(f_map[5][4].data,vgnt->

strcpy(f_map[2][5].data,wshl->

strcpy(f_map[3][5].data,wshl->

strcpy(f_map[4][5].data,wshl->

strcpy(f_map[1][6].data,pstn->

strcpy(f_map[2][6].data,wdp->

strcpy(f_map[3][6].data,wdp->

strcpy(f_map[4][6].data,wshl->

strcpy(f_map[7][6].data,mnt->

strcpy(f_map[0][7].data,mnt->

strcpy(f_map[1][7].data,wdp->

strcpy(f_map[2][7].data,wshl->

strcpy(f_map[3][7].data,wshl->

strcpy(f_map[6][7].data,mnt->

strcpy(f_map[rx][ry].data,p_rover->

if((rx==1&

&

ry==0)||(rx==2&

ry==6)||(rx==3&

ry==6)||(rx==1&

ry==7))

object=9;

action(object,p_rover);

elseif((rx==4&

ry==0)||(rx==5&

ry==0)||(rx==0&

ry==3)||(rx==1&

ry==3)||(rx==7&

ry==6)||(rx==0&

ry==7)||(rx==6&

object=3;

elseif((rx==3&

ry==1)||(rx==4&

ry==1)||(rx==3&

ry==2)||(rx==4&

ry==2)||(rx==4&

ry==3)||(rx==4&

ry==4))

object=4;

ry==3)||(rx==3&

object=5;

elseif((rx==5&

ry==3)||(rx==5&

object=6;

elseif((rx==2&

ry==5)||(rx==3&

ry==5)||(rx==4&

ry==5)||(rx==4&

ry==6)||(rx==2&

ry==7)||(rx==3&

object=8;

elseif(rx==1&

ry==6)

object=13;

i=0;

/*re-allocateito0somapisprintedfromstart*/

i++)/*8by8map*/

{

+----+----+----+----+----+----+----+----+\n"

j++)/*8by8map*/

if(strlen(f_map[i][j].data)!

=0)/*iffunctiontoprintnothingbut4spacesifthereinnothingallocatedin[i][j]*/

|%4s"

f_map[i][j].data);

|"

/*endofcoloumnvisiblemap*/

}

|\n"

/*endoflastcoloumnvisiblemap*/

/*bottomofmap*/

\n"

\270"

GroupB\n"

voidadd_obj(structmap*number,structmap*number_2,structobject_fix*rsny,

structobject_move*anon,structobject_move*rvr,structobject_move*pstn,structrover*p_rover)/*addmovableobjectfunction,*number=aliens,*number_2=rovers*/

intobject,t,f;

charalien;

charrover;

Thisistheaddmovableobjectfunction\n"

howmanyalienswouldyoulike?

sc

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 英语

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1