纯C语言写的一个小型游戏源代码Word文档格式.docx
- 文档编号:18281577
- 上传时间:2022-12-15
- 格式:DOCX
- 页数:14
- 大小:48.22KB
纯C语言写的一个小型游戏源代码Word文档格式.docx
《纯C语言写的一个小型游戏源代码Word文档格式.docx》由会员分享,可在线阅读,更多相关《纯C语言写的一个小型游戏源代码Word文档格式.docx(14页珍藏版)》请在冰豆网上搜索。
intlocation[2];
structmap/*thisisthemapstructure*/
chardata[20];
charadd_data[20];
intamount;
intx;
/*thiswerethesuccessorkeepsit'
sx&
yvalues*/
inty;
structlocation/*thisstructureisforthesuccessorlister*/
floatheight;
charobj;
intselection;
switch(object)
case1:
printf("
\nYouhaveencountered:
ASandyRock\n\n"
);
Thisobjectcanbe:
\n1.\tDestroyed\n2.\tCollected\nPleasechooseaction1or2:
\t"
scanf("
%d"
&
selection);
stats_update(selection,p_rover);
break;
case2:
ASolidRock\n\n"
\n1.\tAvoided\n2.\tCollected\nPleasechooseaction1or2:
if(selection==1)
selection=3;
case3:
AMountain\n\n"
\n1.\tAvoided\nPleaseenter1:
case4:
Dust\n\n"
\n1.\tDriventhrough\n2.\tCollected\nPleasechooseaction1or2:
selection=4;
case5:
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;
default:
\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);
else
|"
/*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?
&
t);
/*userinputofamountofaliens*/
amount=t;
/*savingthenumberinstructuremap-amount*/
howmanyroverswouldyoulike?
f);
/*userinputofamountofrovers*/
amount=f;
show_map(number,number_2,rsny,rsld,mnt,dst,vshr,vgnt,mtre,wshl,
wdp,aagr,anon,rvr,pstn,p_rover);
/*gotoshowmapfunctionwiththenumberofaliensandnumberofrovers*/
voidsuccessor()/*thisfunctionsaskestheuserforthelocationandthenweretheywanttogofromthere,printingoutthatlocation*/
structmaplocation;
intmenu;
intncol,nrow;
/*wecanchangethenvaluedependshowlargethemapyouneed.*/
ncol=8;
nrow=8;
Thisisthesuccessorfunction\n"
Enterthe\nx=\ty=\n"
%d%d"
location.x,&
location.y);
/*savinglocationinmaplocationxandy*/
Enteroperatorchoice\n"
1=left\n"
2=right\n"
3=upwards\n"
4=down\n"
5=quit\n"
menu);
switch(menu)/*menuswitchtoshowthepositionabove,
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 一个 小型 游戏 源代码