欢迎来到天天文库
浏览记录
ID:20206682
大小:31.00 KB
页数:4页
时间:2018-10-11
《简单小拼图源码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、拼图源码#include#include#include#defineWIDTH550#defineHEIGHT600intarr[3][3]={4,1,9,7,2,8,6,3,5,};intarr1[3][3]={1,2,3,4,5,6,7,8,9};voidshowpicture();voidplaygame();voidiswin();charname[10];intflag=1;voidmain(){initgraph(WIDTH,HEIGHT);while(flag){showpicture(
2、);playgame();iswin();}while(1){showpicture();}getch();closegraph();return;}voidshowpicture(){IMAGEimg;for(inti=0;i<3;++i){for(intj=0;j<3;++j){sprintf(name,"%d.jpg",arr[i][j]);getimage(&img,name);putimage(j*180,i*150,&img);}}}voidplaygame(){inttemp=0;charstr=getch();for(intx=0;x<3;++x
3、){for(inty=0;y<3;++y){if(arr[x][y]==9){switch(str){case's':if(x>0){temp=arr[x][y];arr[x][y]=arr[x-1][y];arr[x-1][y]=temp;return;}break;case'w':if(x<2){temp=arr[x][y];arr[x][y]=arr[x+1][y];arr[x+1][y]=temp;return;}break;case'd':if(y>0){temp=arr[x][y];arr[x][y]=arr[x][y-1];arr[x][y-1]=
4、temp;return;}break;case'a':if(y<2){temp=arr[x][y];arr[x][y]=arr[x][y+1];arr[x][y+1]=temp;return;}break;}}}}}voidiswin(){intcount=0;for(inti=0;i<3;++i){for(intj=0;j<3;++j){if(arr[i][j]==arr1[i][j]){++count;}else{return;}}}if(count==9){showpicture();setcolor(WHITE);setfont(40,40,"");ou
5、ttextxy(100,480,"恭喜过关!");flag=0;}}
此文档下载收益归作者所有