欢迎来到天天文库
浏览记录
ID:50599746
大小:55.50 KB
页数:15页
时间:2020-03-12
《纯C语言写的一个小型游戏源代码.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、./*Asimplegame*//*CopyRight:Guanlin*/#include#include#include#include#include#include structobject_fix{charname[20];charid[5];chardesc[500];charaction[30];charim[5];};structobject_move{charname[20];charid[5];chardesc[500];intloc;int
2、pwr;intstrg;charim[5];};structrover{charname[20];charid[5];chardesc[500];intpwr;intstrg;intlocation[2];charim[5];};structmap/*thisisthemapstructure*/{chardata[20];charadd_data[20];intamount;intx;/*thiswerethesuccessorkeepsit'sx&yvalues*/inty;};structlocation/*thisstructureisforthesuccesso
3、rlister*/....{floatheight;charobj;};voidstats_update(intselected,structrover*p_rover){switch(selected){case1:if(p_rover->pwr<7)printf("Youdonothaveenoughpowertoperformthisaction!");else{(p_rover->pwr)-=7;printf("Youhavedestroyedtheobject!");}break;case2:if(p_rover->pwr<3)print
4、f("Youdonothaveenoughpowertoperformthisaction!");elseif(p_rover->strg>90)printf("Youdonothaveenoughstoragespaceforthisobject!");else{(p_rover->pwr)-=3;(p_rover->strg)+=10;printf("Youhavecollectedasampleoftheobject!");}break;case3:p_rover->pwr-=10;/*Distancearoundobject
5、-valuegainedfrommappermodule.1square=-1power*/printf("Youhaveavoidedtheobject!");break;case4:p_rover->pwr-=2;printf("Youhavedriventhroughtheobstacle!");break;case5:if(p_rover->pwr==100)printf("Youdonotneedtochargeup!");else{p_rover->pwr=100;printf("Youhavechargedupyourrove
6、r!");}....break;default:printf("*****ERROR*****InvalidSelection");break;}}voidaction(charobject,structrover*p_rover){intselection;switch(object){case1:printf("Youhaveencountered:ASandyRock");printf("Thisobjectcanbe:1.tDestroyed2.tCollectedPleasechooseaction1or2
7、:t");scanf("%d",&selection);stats_update(selection,p_rover);break;case2:printf("Youhaveencountered:ASolidRock");printf("Thisobjectcanbe:1.tAvoided2.tCollectedPleasechooseaction1or2:t");scanf("%d",&selection);if(selection==1)selection=3;stats_update(s
此文档下载收益归作者所有