版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、#include"stdlib.h"#include"stdio.h"#include"graphics.h"#include"math.h"#include"conio.h "#include"dos.h"#define UP 0x4800#define DOWN 0x5000#define LEFT 0x4b00#define RIGHT 0x4d00#define ESC 0x011b#define F10 0x4400#define MAx_weight 20#def
2、ine MAx_hight 15#define SIZE 20#define STACK_INIT_SIZE 100#define STACKINCREMENT 20#define OK 1#define ERROR 0typedef struct Point int x; int y;Point;typedef struct Node int x,y;int d;Node;typedef struct Satack Node *top; Node *base; int stacksize;Stack;Stack S;char MapMAx_hightMAx_weight=0,0,1,1,1,
3、1,1,1,0,0,0,1,1,1,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,0,0, 1,0,1,0,1,1,1,1,1,1,1,0,1,1,0,1,0,1,0,1, 1,0,1,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,0,1, 1,0,1,1,1,1,0,0,0,1,1,1,1,1,0,1,1,0,0,0, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0, 1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,0, 0,1,0,0,0,1,1,1,0,0,0,0
4、,0,0,0,0,1,1,0,1, 0,1,0,1,0,1,1,0,0,1,1,0,1,1,1,0,1,1,0,1, 0,1,0,1,0,1,0,0,1,1,0,0,0,1,0,1,1,0,0,1, 0,1,0,1,0,1,0,1,1,1,0,1,1,1,0,0,1,1,1,1, 0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,1,1,0,0,1, 0,0,0,0,0,1,1,1,0,1,1,1,1,1,0,0,1,0,1,1, 1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,1,1,1,0,1,0,1,1,0,0,1,1,1,1,
5、0,0 ;void Init() int gd=DETECT,gm; initgraph(&gd,&gm,""); cleardevice();void MoveTo(Point point,Point oldpoint ) setcolor(63); rectangle(oldpoint.x*SIZE+8+120,oldpoint.y*SIZE+8+90,oldpoint.x*SIZE+12+120,oldpoint.y*SIZE+12+90); setfillstyle(SOLID_FILL,63); floodfill(oldpoint.x*SIZE+
6、10+120,oldpoint.y*SIZE+10+90,63); setcolor(3); circle(point.x*SIZE+10+120,point.y*SIZE+10+90,2); setfillstyle(SOLID_FILL,3); floodfill(point.x*SIZE+10+120,point.y*SIZE+10+90,3);void Print_Map(Point point) int i,j; cleardevice(); setcolor(4); line(119,89,MAx_weight*SIZE+121,89); line(MAx_weight*SIZE+
7、121,89,MAx_weight*SIZE+121,MAx_hight*SIZE+91); line(MAx_weight*SIZE+121,MAx_hight*SIZE+91,119,MAx_hight*SIZE+91); line(119,MAx_hight*SIZE+91,119,89); setfillstyle(SOLID_FILL,63); floodfill(130,100,4); for(i=0;i<MAx_hight;i+) for(j=0;j<MAx_weight;j+) if(Mapij=1) setcolor(0); rectangle(j*SIZE+12
8、0,i*SIZE+90,(j+1)*SIZE+120,(i+1)*SIZE+90); setfillstyle(SOLID_FILL,0); floodfill(j*SIZE+4+120,i*SIZE+4+90,0); setcolor(3); circle(point.x*SIZE+10+120,point.y*SIZE+10+90,2); setfillstyle(SOLID_FILL,3); floodfill(point.x*SIZE+10+120,point.y*SIZE+10+90,3); setcolor(EGA_DARKGRAY); settextstyle(2,0,3); o
9、uttextxy(460,460,"YouCanUseFIOToGetHelp"); setcolor(EGA_LIGHTGREEN); rectangle(j*SIZE+120-17,i*SIZE+90-14,j*SIZE+120-9,i*SIZE+90-6); setfillstyle(SOLID_FILL,EGA_LIGHTGREEN); floodfill(j*SIZE+120-10,i*SIZE+90-10,EGA_LIGHTGREEN); line(j*SIZE+120-9,i*SIZE+90-3,j*SIZE+120-9,i*SIZE+90-17); line
10、(j*SIZE+120-9,i*SIZE+90-17,j*SIZE+120-3,i*SIZE+90-10); line(j*SIZE+120-9,i*SIZE+90-3,j*SIZE+120-3,i*SIZE+90-10); setfillstyle(SOLID_FILL,EGA_LIGHTGREEN); floodfill(j*SIZE+120-5,i*SIZE+90-10,EGA_LIGHTGREEN);void Print_body(int i) setcolor(3); circle(i-8,380,10); setfillstyle(SOLID_FILL,3); floodfill(
11、i,380,3); setcolor(EGA_LIGHTGRAY); circle(i,380,10); setfillstyle(SOLID_FILL,EGA_LIGHTGRAY); floodfill(i,380,EGA_LIGHTGRAY);void StartGame() int i; cleardevice(); setcolor(EGA_YELLOW); settextstyle(0,0,3); outtextxy(120,100,"Game") ; outtextxy(265,100,"Of") ; outtextxy(360,100,&q
12、uot;Maze") ; setcolor(63); line(270,480,280,400); line(370,480,360,400); line(280,400,0,400); line(285,360,0,360); line(360,400,640,400); line(355,360,640,360); line(285,360,295,280); line(355,360,345,280); line(293,280,345,280); setfillstyle(SOLID_FILL,3); floodfill(280,370,63); for(i=0;i<2
13、72;i+=8) Print_body(i); /*sleep(1);*/ setcolor(0); arc(264,387,0,180,3); setcolor(63); setfillstyle(SOLID_FILL,63); fillellipse(260,378,2,3); fillellipse(268,378,2,3); setcolor(0); setfillstyle(SOLID_FILL,0); fillellipse(260,380,1,2); fillellipse(268,380,1,2); setcolor(63); setfillstyle(SOLID_FILL,6
14、3); fillellipse(240,320,40,20); fillellipse(240,360,10,5); fillellipse(246,378,3,2); setcolor(0); arc(240,308,0,135,5); arc(240,308,270,360,5); line(240,313,240,320); setfillstyle(SOLID_FILL,0); fillellipse(240,328,2,2); setcolor(EGA_DARKGRAY); settextstyle(2,0,3); outtextxy(180,180,"whichWayIs
15、Right,CanYouHelpMe") ; outtextxy(200,220,"PressAnyKeyToContiune") ; getch();void EndGame() cleardevice(); setcolor(5); settextstyle(0,0,5); outtextxy(200,150,"YOUWIN") ; setcolor(63); settextstyle(0,0,2); outtextxy(140,300,"thankyouforyousupport") ; getch();void In
16、it_Stack() S.base=(Node*)malloc(STACK_INIT_SIZE*sizeof(Node) ; if(!S.base)exit(0); S.top=S.base; S.stacksize=STACK_INIT_SIZE;int Push(Node e) if(S.top-S.base>=S.stacksize) S.base=(Node*)realloc(S.base,(S.stacksize+STACKINCREMENT)*sizeof(Node); if(!S.base)exit(0); S.top=S.base+S.stacksize; S.stack
17、size+=STACKINCREMENT; S.top->x=e.x; S.top->y=e.y; S.top->d=e.d; S.top+; return OK; Node Pop() Node e; e=*-S.top; return e;int StackEmpty() if(S.top=S.base) return OK; else return ERROR;int printstack() Node *now; now=S.base; while(!(now=S.top) printf("%d,%dt",now->x,now->y);
18、 now+; return OK;void TheEnd() cleardevice(); setcolor(5); settextstyle(0,0,5); outtextxy(170,150,"YouLost") ; setcolor(63); settextstyle(0,0,2); outtextxy(140,300,"thankyouforyousupport") ; outtextxy(180,340,"PlayUpNextTime") ; getch();void Out_Line() Node *now; Node *
19、q; now=S.base; q=S.base; setcolor(EGA_LIGHTGREEN); while(1) now+; if(now=S.top) break; line(now->y*20+120+10,now->x*20+90+10,q->y*20+120+10,q->x*20+90+10); q=now; void autoPlay(Point point) int i,j,d; int a,b; Node elem; int diradd42=0,1,1,0,0,-1,-1,0; /*下 右 上 左 */ Init_Stack(); Mappoint
20、.xpoint.y=2; elem.x=0; elem.y=0; elem.d=-1; Push(elem); while(!StackEmpty() elem=Pop(); i=elem.x; j=elem.y; d=elem.d+1; while(d<4) a=i+diraddd0; b=j+diraddd1; if(a>=0&&b>=0) if(a=14 && b=19 && Mapab=0) elem.x=i; elem.y=j; elem.d=d; Push(elem); elem.x=a; elem.y=b; ele
21、m.d=d; Push(elem); Out_Line(); setfillstyle(SOLID_FILL,0); floodfill(459,460,4); setcolor(EGA_DARKGRAY); settextstyle(2,0,3); outtextxy(460,460,"PressAnyKeyToContiune") ; getch(); TheEnd(); exit(0); return ; else if(Mapab=0) Mapab=2; elem.x=i; elem.y=j; elem.d=d; Push(elem); i=a; j=b; d=-1
22、; d+; void Play_Game() int key; Point point; Point oldpoint; char flag; point.x=0; point.y=0; flag=0; Print_Map(point); while(1) while(kbhit() key=bioskey(0); if(key=ESC ) flag=1; break; else if(key=UP) if(Mappoint.y-1point.x=0&&point.y-1>=0) oldpoint=point; point.y-=1; MoveTo( point,oldpoint); else if(key=DOWN) if(Mappoint.y+1point.x=
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年甘肃农业职业技术学院高职单招职业适应性测试模拟试题及答案详细解析
- 2026年浙江舟山群岛新区旅游与健康职业学院单招综合素质考试参考题库含详细答案解析
- 2026年黑龙江农业工程职业学院单招职业技能考试模拟试题含详细答案解析
- 2026年韶关学院高职单招职业适应性测试备考试题及答案详细解析
- 2026江西省农业科学院高层次人才招聘21人参考考试题库及答案解析
- 2026年武汉软件工程职业学院单招职业技能考试参考题库含详细答案解析
- 2026年山西艺术职业学院单招职业技能考试模拟试题含详细答案解析
- 2026年天津医学高等专科学校单招综合素质笔试备考题库含详细答案解析
- 2026山东中医药大学附属医院招聘高级岗位工作人员2人考试重点题库及答案解析
- 2026年黑龙江交通职业技术学院高职单招职业适应性测试备考题库及答案详细解析
- 2026云南昆明市公共交通有限责任公司总部职能部门员工遴选48人笔试模拟试题及答案解析
- 2025至2030中国数字经济产业发展现状及未来趋势分析报告
- 上海市松江区2025-2026学年八年级(上)期末化学试卷(含答案)
- 导管室护理新技术
- 中国信通服务:2025算力运维体系技术白皮书
- 2026年焦作大学单招试题附答案
- 电力行业五新技术知识点梳理
- 《DLT 849.1-2004电力设备专用测试仪器通 用技术条件 第1部分:电缆故障闪测仪》专题研究报告 深度
- 餐饮业店长运营效率考核表
- 超市安全生产协议书
- 福建省漳州市2024-2025学年八年级上学期期末考试数学试卷(北师大版A卷)(含详解)
评论
0/150
提交评论