#include"stdio.h"#include"windows.h"#include"easyx.h"#include"graphics.h"#include"math.h"//数学函数#include"time.h"//时间函数#include"conio.h"//非标准头文件 模拟键盘操作#include"mmsystem.h"//媒体控制库文件 音乐#pragmacomment(lib,"winmm.lib")//媒体控制库文件#definePI3.14//深度寻路int map[8][8]={1,1,1,1,1,1,1,1,1,3,1,0,0,1,0,1,1,0,1,1,1,0,0,1,1,0,1,0,1,0,1,1,1,0,0,0,0,0,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,0,2,1,1,1,1,1,1,1,1,1,};int len =0;//计数
IMAGE img[5];int k, b;//记录位置structpositon{int x;int y;}pos[64];//入栈voidpush(int x,int y){
pos[len].x = x;
pos[len].y = y;int tmp = map[x][y];
map[x][y]=6;
len++;}//出栈//删除栈顶的元素voidpop(){
len--;}//初始化图片voidinitImg(){//sprintf()格式化写入字符串char str[30]={0};for(int i =0; i <5; i++){sprintf(str,"%d.gif", i);//第一个参数:字符串数组名loadimage(&img[i], str,80,80);//最后两个是图片的宽和高 如果没有那么大 就会被等比例拉伸}}voiddrawMap(){for(int i =0; i <8; i++){for(int j =0; j <8; j++){switch(map[i][j]){case1:putimage(j *80, i *80,&img[1]);break;case0:putimage(j *80, i *80,&img[0]);//0代表break;case6:putimage(j *80, i *80,&img[3]);break;case9:putimage(j *80, i *80,&img[0]);break;case2:putimage(j *80, i *80,&img[2]);//她break;case3:putimage(j *80, i *80,&img[3]);//我break;case7:putimage(j *80, i *80,&img[4]);//我&她break;}}}}voidwelcome(){settextcolor(YELLOW);//设置字体的颜色//字体从0越来越大for(int i =0; i <50; i++){//圆的参数方程 int x =250+180*sin(PI *2* i /60);int y =300+180*cos(PI *2* i /60);cleardevice();settextstyle(i,0,"宋体");outtextxy(x, y,"七夕情人节");Sleep(25);}_getch();//暂停cleardevice();//清除屏幕settextstyle(20,0,"宋体");//50代表高 0自适应宽度//写情诗outtextxy(50,150,"我想以世纪和你在一起");outtextxy(50,200,"I want to be with you in the century");outtextxy(50,250,"跟你说话,真是为数不多的开心时光");outtextxy(50,300,"Talking to you is really one of the few happy times");outtextxy(50,350,"钟于,忠于,衷于,终于,我们在一起了很多天");outtextxy(50,400,"Zhong Yu,loyal,sincere,and finally,We were together ");outtextxy(50,450,"for many days");//很重要outtextxy(300,500,"--------PengAoLin");}voidstar(int x,int y);//画星星voiddrawmoon();//画月亮voiddrawstar();//画星空voidstarflower1();//烟花绽放1voidstarflower2();//烟花绽放2voidYanHua(){int i;cleardevice();line(100,421,540,421);// 画地平线drawstar();//画星空while(!kbhit()){starflower1();//烟花绽放函数1starflower2();//烟花绽放函数2Sleep(10);}getch();closegraph();// 关闭绘图窗口}voidBiaoBaiShi(){cleardevice();welcome();//指定的坐标输出文字settextcolor(BLUE);//设置字体颜色settextstyle(40,0,"宋体");//设置字体的格式 40代表宽 0代表自适应宽度outtextxy(20,50,"七夕情人节");//指定第一个字的输出位置settextstyle(30,0,"楷体");//设置字体的格式 40代表宽 0代表自适应宽度settextcolor(GREEN);//设置字体颜色outtextxy(80,100,"------To Zhang Xi");_getch();YanHua();return;}intmain(){initgraph(80*8,80*8);initImg();drawMap();int x =1, y =1;push(x, y);while(1){
k = x, b = y;//0 1 2 3代表上下左右for(int i =0; i <5; i++){switch(i){case0:
x--;break;case1:
x++;break;case2:
y--;break;case3:
y++;break;case4://回退
map[x][y]=9;pop();break;}if(map[x][y]==0){push(x, y);break;}elseif(x ==6&& y ==6){
map[x][y]=7;for(int i =0; i < len; i++){drawMap();}_getch();BiaoBaiShi();//程序出口}else{
x = pos[len -1].x;
y = pos[len -1].y;//map[k][b] = 9;}}Sleep(100);system("cls");drawMap();}return0;}voidstar(int x,int y)//画星星函数{int i, a;int n =5;int x1[5], y1[5], x2[5], y2[5];setcolor(YELLOW);for(i =0; i <5; i++){
x1[i]=(int)(x + n*cos(i *72* PI /180)+1);
y1[i]=(int)(y + n*sin(i *72* PI /180)+1);
x2[i]=(int)(x + n /2*cos(i *72* PI /180+ PI /5)+1);
y2[i]=(int)(y + n /2*sin(i *72* PI /180+ PI /5)+1);}for(i =0; i<5; i++){
a = i +1;if(a>4) a =0;line(x1[i], y1[i], x2[i], y2[i]);//两点间画直线line(x2[i], y2[i], x1[a], y1[a]);}}voiddrawmoon()//画月亮{setfillcolor(WHITE);//fillcircle(550,80,40);//画圆(有边框)solidcircle(550,80,40);//画圆(无边框)}voiddrawstar()//画星空{int a[]={40,250,140,140,90,350,300};int b[]={40,25,99,100,98,60,78}, i;//setfillstyle(1,14);for(i =0; i <10; i++){star(a[i], b[i]);floodfill(a[i], b[i], YELLOW);}drawmoon();}voidstarflower1()//烟花绽放函数1{double h, v, dv;// 高度, 速度(方向向下),加速度(每 1/50 秒){
h =470, v =54, dv =9.8/10;while(h >=200){
h -=(v - dv /2);
v = v *0.9;setcolor(GREEN);setfillcolor(RED);//填充颜色为蓝色fillcircle(300,int(h),5);Sleep(20);// 延时// 擦掉球 setcolor(BLACK);setfillcolor(BLACK);//填充颜色为黑色fillcircle(300,int(h),5);Sleep(10);}}}voidstarflower2()//烟花绽放函数2{int i =0, j, n =60, x =300, y =200, px, py;while(1){if(i <100){for(j =0; j < n; j++){
px =(int)(x + i*cos(j *360/ n*PI /180)+1);
py =(int)(y + i*sin(j *360/ n*PI /180)+1);putpixel(px -1, py, BLUE);putpixel(px, py +1, BLUE);putpixel(px +1, py -1, YELLOW);putpixel(px, py -1, YELLOW);putpixel(px +1, py, RED);putpixel(px +1, py +1, RED);}//画圆擦掉Sleep(10);setfillcolor(BLACK);solidcircle(300,200,101);}
i +=2;if(i >=100)break;}}