欢迎来到天天文库
浏览记录
ID:35689608
大小:121.50 KB
页数:15页
时间:2019-04-12
《纯c语言写地一个小型游戏 源代码》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
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];ch
2、arid[5];chardesc[500];intloc;intpwr;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
3、'sx&yvalues*/inty;};structlocation/*thisstructureisforthesuccessorlister*/{floatheight;charobj;};voidstats_update(intselected,structrover*p_rover){switch(selected){case1:if(p_rover->pwr<7)printf("Youdonothaveenoughpowertoperformthisaction!");else{(
4、p_rover->pwr)-=7;printf("Youhavedestroyedtheobject!");}break;case2:if(p_rover->pwr<3)printf("Youdonothaveenoughpowertoperformthisaction!");elseif(p_rover->strg>90)printf("Youdonothaveenoughstoragespaceforthisobject!");else{(p_rover->pwr
5、)-=3;(p_rover->strg)+=10;printf("Youhavecollectedasampleoftheobject!");}break;case3:p_rover->pwr-=10;/*Distancearoundobject-valuegainedfrommappermodule.1square=-1power*/printf("Youhaveavoidedtheobject!");break;case4:p_rover->pwr-=2;printf("Youhaved
6、riventhroughtheobstacle!");break;case5:if(p_rover->pwr==100)printf("Youdonotneedtochargeup!");else{p_rover->pwr=100;printf("Youhavechargedupyourrover!");}break;default:printf("*****ERROR*****InvalidSelection");break;}}voidaction(c
7、harobject,structrover*p_rover){intselection;switch(object){case1:printf("Youhaveencountered:ASandyRock");printf("Thisobjectcanbe:1.tDestroyed2.tCollectedPleasechooseaction1or2:t");scanf("%d",&selection);stats_update(selection,p_rover);break;
8、case2:printf("Youhaveencountered:ASolidRock");printf("Thisobjectcanbe:1.tAvoided2.tCollectedPleasechooseaction1or2:t");scanf("%d",&selection);if(selection==1)selection=3;stats_update(selection,
此文档下载收益归作者所有