DEVC++实现推箱子小游戏
推箱子小游戏(基于DEVC++),供大家参考,具体内容如下
#include#include #include #include usingnamespacestd; voidGame_Menu(HANDLEhout); voidGame_description(HANDLEhout); voidgotoxy(HANDLEhout,intx,inty); intDrawMap(HANDLEhout); voidMove(HANDLEhout); intfinish(); voidsetmap(intn); voidcolor(intm); boolflag=true; intpass=1; #defineR10 #defineC10 #defineframex20 #defineframey14 intmap[R][C]={0}; //关卡1 intmap1[R][C]={ {0,0,1,1,1,0,0,0}, {0,0,1,3,1,0,0,0}, {0,0,1,0,1,1,1,1}, {1,1,1,0,0,4,3,1}, {1,3,4,4,0,1,1,1}, {1,1,1,5,4,1,0,0}, {0,0,0,1,3,1,0,0}, {0,0,0,1,1,1,0,0} }; //地图2(关卡2) intmap2[R][C]={ {1,1,1,1,1,0,0,0,0,0}, {1,5,0,0,1,0,0,0,0,0}, {1,0,4,4,1,0,1,1,1,0}, {1,0,4,0,1,0,1,3,1,0}, {1,1,1,0,1,1,1,3,1,0}, {0,1,1,0,0,0,0,3,1,0}, {0,1,0,0,0,1,0,0,1,0}, {0,1,0,0,0,1,1,1,1,0}, {0,1,1,1,1,1,0,0,0,0} }; //地图3(关卡3) intmap3[R][C]={ {0,0,0,1,1,1,1,1,1,1}, {0,0,1,1,0,0,1,0,5,1}, {0,0,1,0,0,0,1,0,0,1}, {0,0,1,4,0,4,0,4,0,1}, {0,0,1,0,4,1,1,0,0,1}, {1,1,1,0,4,0,1,0,1,1}, {1,3,3,3,3,3,0,0,1,0}, {1,1,1,1,1,1,1,1,1,0}, }; voidGame_Menu(HANDLEhout){//游戏开始菜单 system("cls"); gotoxy(hout,framex,1); cout<<"*******************"; gotoxy(hout,framex,3); cout<<"推箱子"; gotoxy(hout,framex,5); cout<<"按s或S开始"; gotoxy(hout,framex,7); cout<<"按q或Q退出"; gotoxy(hout,framex,9); cout<<"游戏前关闭中文输入"; gotoxy(hout,framex,11); cout<<"*******************"; _getch(); }; voidGame_description(HANDLEhout){//操作提示 system("cls"); gotoxy(hout,framex,1); cout<<"*****************************"; gotoxy(hout,framex,3); cout<<"按方向键上下左右移动"; gotoxy(hout,framex,5); cout<<"所有箱子到达目的地游戏胜利"; gotoxy(hout,framex,7); cout<<"按q或Q退出"; gotoxy(hout,framex,9); cout<<"*****************************"; }; voidgotoxy(HANDLEhout,intx,inty){ COORDpos; pos.X=x; pos.Y=y; SetConsoleCursorPosition(hout,pos); }; voidprint(inti){//根据map值输出相应的图形 switch(i){ case0: color(0x7); cout<<"";//空地■★□?◇◆??¤ break; case1: color(8); cout<<"■";//墙体 break; case3: color(0xE); cout<<"◇";//目的地 break; case4: color(4); cout<<"□";//箱子 break; case5: color(3); cout<<"♀";//人 break; case7://4+3箱子到达目的地 color(6); cout<<"◆"; break; case8://5+3人与目的地重合 color(3); cout<<"♀"; break; default: break; } } intDrawMap(HANDLEhout){//新的关卡开始时载入地图 //HANDLEhout=GetStdHandle(STD_OUTPUT_HANDLE); gotoxy(hout,framex+C,framey-3); color(0xF); cout<<"第"< 3){ gotoxy(hout,framex,framey); cout<<"您已通过全部关卡!"; getch(); flag=false; } else{ setmap(pass); Game_description(hout); DrawMap(hout); } } } return0; }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。