资源预览内容
第1页 / 共14页
第2页 / 共14页
第3页 / 共14页
第4页 / 共14页
第5页 / 共14页
第6页 / 共14页
第7页 / 共14页
第8页 / 共14页
第9页 / 共14页
第10页 / 共14页
亲,该文档总共14页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
/* A simple game*/*CopyRight: Guanlin*/#include#include#include#include#include#includestruct object_fixchar name20;char id5;char desc500;char action30;char im5;struct object_movechar name20;char id5;char desc500;int loc;int pwr;int strg;char im5;struct roverchar name20;char id5;char desc500; int pwr;int strg;int location2;char im5;struct map /* this is the map structure*/char data20;char add_data20;int amount;int x; /* this were the successor keeps its x & y values*/int y;struct location /*this structure is for the successor lister*/float height;char obj;void stats_update(int selected, struct rover *p_rover)switch (selected)case 1:if(p_rover-pwr pwr) -= 7;printf(You have destroyed the object!nn);break;case 2:if(p_rover-pwr strg 90)printf(nnYou do not have enough storage space for this object!nn);else(p_rover-pwr) -= 3;(p_rover-strg) += 10;printf(You have collected a sample of the object!nn);break;case 3:p_rover-pwr -= 10; /*Distance around object- value gained from mapper module. 1 square = -1 power*/printf(You have avoided the object!nn);break;case 4:p_rover-pwr -= 2; printf(You have driven through the obstacle!nn);break;case 5:if(p_rover-pwr = 100)printf(nnYou do not need to charge up!nn);elsep_rover-pwr = 100;printf(You have charged up your rover!nn);break;default:printf(nn*ERROR*nInvalid Selectionnn);break;void action(char object, struct rover *p_rover)int selection;switch(object)case 1:printf(nYou have encountered: A Sandy Rocknn);printf(This object can be:n1.tDestroyedn2.tCollectednPlease choose action 1 or 2:t);scanf(%d, &selection);stats_update(selection, p_rover);break;case 2:printf(nYou have encountered: A Solid Rocknn);printf(This object can be:n1.tAvoidedn2.tCollectednPlease choose action 1 or 2:t);scanf(%d, &selection);if (selection = 1)selection = 3;stats_update(selection, p_rover);break;case 3:printf(nYou have encountered: A Mountainnn);printf(This object can be:n1.tAvoidednPlease enter 1:t);scanf(%d, &selection);selection = 3;stats_update(selection, p_rover);break;case 4:printf(nYou have encountered: Dustnn);printf(This object can be:n1.tDriven throughn2.tCollectednPlease choose action 1 or 2:t);scanf(%d, &selection);if (selection = 1)selection = 4;stats_update(selection, p_rover);break;case 5:printf(nYou have encountered: A Sheer Valleynn);printf(This object can be:n1.tAvoidednPlease enter 1:t);scanf(%d, &selection);selection = 3;stats_update(selection, p_rover);break;case 6:printf(nYou have encountered: A Gentle Valleynn);printf(This object can be:n1.tDriven throughn2.tAvoidednPlease choose action 1 or 2:t);scanf(%d, &selection);if (selection = 1)selection = 4;if (selection = 2)selection = 3;stats_update(selection, p_rover);break;case 7:printf(nYou have encountered: A Martian Treenn);printf(This object can be:n1.tDestroyedn2.tCollectedn3.tAvoidednPlease choose action 1, 2 or 3:t);scanf(%d, &selection);stats_update(selection, p_rover);break;case 8:printf(nYou have encountered: Shallow Waternn);printf(This object can be:n1.tDriven throughn2.tCollectedn3.tAvoidednPlease choose action 1, 2 or 3:t);scanf(%d, &selection);if (selection = 1)selection = 4;stats_update(selection, p_rover);break;case 9:printf(nYou have encountered: Deep Waternn);printf(This object can be:n1.tAvoidedn2.tCollectednPlease choose action 1 or 2:t);scanf(%d, &selection);if (selection = 1)selection = 3;stats_update(selection, p_rover);break;case 10:printf(nYou have encountered: An Aggressive Aliennn);printf(This object can be:n1.tDestroyednPlease enter 1:t);scanf(%d, &selection);selection = 1;stats_update(selection, p_rover);break;case 11:printf(nYou have encountered: A Non-Aggressive Aliennn);printf(This object can be:n1.tAvoidednPlease enter 1:t);scanf(%d, &selection);selection = 3;stats_update(selection, p_rover);break;case 12:printf(nYou have encountered: Another Rovernn);printf(This object can be:n1.tAvoidednPlease enter 1:t);scanf(%d, &selection);selection = 3;stats_update(selection, p_rover);break;case 13:printf(nYou have encountered: A Power Stationnn);printf(You can:n1.tCharge upn2.tAvoidnPlea
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号