C语言推箱子代码.doc_第1页
C语言推箱子代码.doc_第2页
C语言推箱子代码.doc_第3页
C语言推箱子代码.doc_第4页
C语言推箱子代码.doc_第5页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#include#includeint i,j,steps = 0,gk = 1;char command,t,m = 0,n = 0;int map_1811,map811 = 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,0,1,0,0,6,0,0,4,1,0,0,0,1,3,0,2,0,0,4,1,0,0,0,1,0,0,1,1,1,1,1,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;int map_2811 = 0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,4,0,1,0,0,0,0,1,1,1,1,0,0,1,1,0,0,0,1,0,0,0,3,2,0,1,0,0,0,1,0,1,1,0,0,0,1,0,0,0,1,0,6,0,0,0,0,1,1,0,0,1,1,1,1,0,0,0,4,1,0,0,0,0,0,1,1,1,1,1,1,0,0;int map_3811 = 0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,4,4,1,0,0,0,0,1,1,1,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,0,1,1,1,0,1,6,2,0,1,0,0,0,0,1,0,0,3,0,0,1,0,0,0,0,1,1,1,1,1,1,1,0,0;typedef struct positionint x;int y;location;location agg3;/全部通过void clearance()if(mapagg1.xagg1.y = 5&mapagg2.x + nagg2.y + m = 5&gk = 3)printf(你赢了!n);system(pause);exit(0);/判断是否通过void control_adopt()if(mapagg1.xagg1.y = 5&mapagg2.x + nagg2.y + m = 5)if(gk != 3)for(i = 0;i 8;i+)for(j = 0;j 11;j+)mapij = map_2ij;map_2ij = map_3ij;map_1ij = mapij;gk+;steps = 0;/重新开始void control_reset(char reset_1)if(reset_1 = f)for(i = 0;i 8;i+) for(j = 0;j 11;j+)mapij = map_1ij;steps = 0;/结束void control_end(char end_0)if(end_0 = t)exit(0);/控制方向 + 箱子堵住陷阱void control_direction(char direction_)if(direction_ = d|direction_ = w|direction_ = a|direction_ = s)if(direction_ = d)m = 1;if(direction_ = a)m = -1;if(direction_ = w)n = -1;if(direction_ = s)n = 1;if(agg0.x + n = agg1.x&(agg0.y + m) = agg1.y&mapagg1.x + nagg1.y + m != 1&mapagg1.xagg1.y != 5)if(mapagg1.x + nagg1.y + m = 4)mapagg1.xagg1.y = 0;mapagg1.x + nagg1.y + m = 5;agg1.y = agg1.y + m;agg1.x = agg1.x + n;elset = mapagg1.x + nagg1.y + m;mapagg1.x + nagg1.y + m = mapagg1.xagg1.y;mapagg1.xagg1.y = t;agg1.y = agg1.y + m;agg1.x = agg1.x + n;/第二个箱子的判断条件if(agg0.x + n = agg2.x&(agg0.y + m) = agg2.y&mapagg2.x + nagg2.y + m != 1&mapagg2.xagg2.y != 5)if(mapagg2.x + nagg2.y + m = 4)mapagg2.xagg2.y = 0;mapagg2.x + nagg2.y + m = 5;agg2.y = agg2.y + m;agg2.x = agg2.x + n;elset = mapagg2.x + nagg2.y + m;mapagg2.x + nagg2.y + m = mapagg2.xagg2.y;mapagg2.xagg2.y = t;agg2.y = agg2.y + m;agg2.x = agg2.x + n;if(mapagg0.x + nagg0.y + m = 0)t = mapagg0.x + nagg0.y + m;mapagg0.x + nagg0.y + m = mapagg0.xagg0.y;mapagg0.xagg0.y = t;agg0.y = agg0.y + m;agg0.x = agg0.x + n;steps+;m = 0;n = 0;/输出,寻找1,2,3void control_output()printf(关卡%d:n,gk);printf(步数:%dn,steps);for(i = 0;i 8;i+)for(j = 0;j 11;j+)if(mapij = 1)printf();if(mapij = 0)printf();if(mapij = 2)printf();agg1.x = i;agg1.y = j;if(mapij = 3)printf();agg0.x = i;agg0.y = j;if(mapij = 4)printf();if(mapij = 5)printf();if(mapij = 6)printf();agg2.x = i;agg2.y = j;printf(n);printf(w,a,s,d控制方向,t退出游戏,f重新开始!n);/输入指令void input_command()while(1)scanf(%c,&command);if(command = w|command = a|command = s|command = d|command = t|command = f)break;main()for(i = 0;i 8;i+)for(j = 0;j 12;j+)map_1ij = mapij;while(1)control_output();input_command();control_dir

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论