ImageVerifierCode 换一换
格式:DOCX , 页数:14 ,大小:19.62KB ,
资源ID:7878260      下载积分:12 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/7878260.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(完整word版纯C语言写的一个小型游戏 源代码.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

完整word版纯C语言写的一个小型游戏 源代码.docx

1、完整word版纯C语言写的一个小型游戏 源代码/* 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 i

2、d5;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_upda

3、te(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

4、 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(n

5、nYou 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 obje

6、ct 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

7、= 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 obje

8、ct 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);s

9、election = 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(select

10、ion, 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

11、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

12、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);br

13、eak;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 e

14、nter 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.tAvoidnPlease choose action 1 or 2:t);scanf(%d, &selection);if (selection = 1)selection = 5;if (selection = 2)selection = 3;sta

15、ts_update(selection, p_rover);break;default:printf(nn*ERROR*nn);break;void show_map(struct map *number, struct map *number_2, struct object_fix *rsny, struct object_fix *rsld, struct object_fix *mnt, struct object_fix *dst, struct object_fix *vshr, struct object_fix *vgnt, struct object_fix *mtre, s

16、truct object_fix *wshl, struct object_fix *wdp, struct object_move *aagr, struct object_move *anon, struct object_move *rvr, struct object_move *pstn, struct rover *p_rover) /*the show map function calling number and number_2 from the map structure to see if moveable objects are needed*/struct map f

17、_map88; /*8 by 8 map*/int i,j, rx, ry, object; /*this is your x and y value in your map (f_map)*/system(cls); /* this is your x and y value in your map (f_map)*/srand(time(NULL); /*calling the time from include to gather random variables*/for(i=0;i8;i+) /*for loop to copy all your fixed object lists

18、 into f_map so they can be displayed*/for(j=0;jamount0) /*this is looking at the add function to see weather or not there are aliens in f_map*/for(i=0;iamount;i+) /*allocating the number of aliens in f_map*/strcpy(f_maprand()%8rand()%8.data, anon-im); /*randomizing their position*/if(number_2-amount

19、0) /*repeat of above just for rovers instead*/for(i=0;iamount;i+)strcpy(f_maprand()%8rand()%8.data, rvr-im);rx= p_rover-location0;ry= p_rover-location1;strcpy(f_map10.data, wdp-im);strcpy(f_map40.data, mnt-im);strcpy(f_map50.data, mnt-im);strcpy(f_map31.data, dst-im);strcpy(f_map41.data, dst-im);str

20、cpy(f_map32.data, dst-im);strcpy(f_map42.data, dst-im);strcpy(f_map03.data, mnt-im);strcpy(f_map13.data, mnt-im);strcpy(f_map33.data, vshr-im);strcpy(f_map43.data, dst-im);strcpy(f_map53.data, vgnt-im);strcpy(f_map34.data, vshr-im);strcpy(f_map44.data, dst-im);strcpy(f_map54.data, vgnt-im);strcpy(f_

21、map25.data, wshl-im);strcpy(f_map35.data, wshl-im);strcpy(f_map45.data, wshl-im);strcpy(f_map16.data, pstn-im);strcpy(f_map26.data, wdp-im);strcpy(f_map36.data, wdp-im);strcpy(f_map46.data, wshl-im);strcpy(f_map76.data, mnt-im);strcpy(f_map07.data, mnt-im);strcpy(f_map17.data, wdp-im);strcpy(f_map27

22、.data, wshl-im);strcpy(f_map37.data, wshl-im);strcpy(f_map67.data, mnt-im);strcpy(f_maprxry.data, p_rover-im);if(rx = 1 & ry = 0) | (rx = 2 & ry = 6) |(rx = 3 & ry = 6) |(rx = 1 & ry = 7)object = 9;action(object, p_rover);else if(rx = 4 & ry = 0) | (rx = 5 & ry = 0) | (rx = 0 & ry = 3) | (rx = 1 & r

23、y = 3) | (rx = 7 & ry = 6) | (rx = 0 & ry = 7) | (rx = 6 & ry = 7)object = 3;action(object, p_rover);else if(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;action(object, p_rover);else if(rx = 3 & ry = 3) | (rx = 3 & ry =

24、4)object = 5;action(object, p_rover);else if(rx = 5 & ry = 3) | (rx = 5 & ry = 4)object = 6;action(object, p_rover);else if(rx = 2 & ry = 5) | (rx = 3 & ry = 5 ) | (rx = 4 & ry = 5) | (rx = 4 & ry = 6) |(rx = 2 & ry = 7) | (rx = 3 & ry = 7)object = 8;action(object, p_rover);else if(rx = 1 & ry = 6)o

25、bject = 13;action(object, p_rover);i=0; /*re-allocate i to 0 so map is printed from start*/for(i=0;i8;i+) /*8 by 8 map*/ printf(+-+-+-+-+-+-+-+-+n);for(j=0;j8;j+) /*8 by 8 map*/if(strlen(f_mapij.data)!=0) /*if function to print nothing but 4 spaces if there in nothing allocated in ij*/printf(|%4s,f_

26、mapij.data);elseprintf(| ); /*end of coloumn visible map*/ printf(|n); /*end of last coloumn visible map*/printf(+-+-+-+-+-+-+-+-+n); /*bottom of map*/printf(n);printf(270);printf(Group Bn);void add_obj(struct map *number, struct map *number_2, struct object_fix *rsny, struct object_fix *rsld, struc

27、t object_fix *mnt, struct object_fix *dst, struct object_fix *vshr, struct object_fix *vgnt, struct object_fix *mtre, struct object_fix *wshl, struct object_fix *wdp, struct object_move *aagr, struct object_move *anon, struct object_move *rvr, struct object_move *pstn, struct rover *p_rover) /* add movable object function, *number=aliens, *number_2=rovers*/int object, t, f;char alien; char rover;printf(This is the add movable object functionn);printf(how many aliens would

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

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