游戏源代码在最下面↓
这是自己用写的C语言推箱子小游戏,总共有两个版本,第一个是控制台应用程序,第二个是图形界面程序。第一个控制台的程序大约写了十几天,在这期间写完后一直在修改,修改了很多次,但是可能还有一些小的bug,不过不影响游戏。控制台程序目前的版本是2.6.5,这个小游戏我写了四十关。代码大约有一千六百多行,代码我都发到了下面,控制台版本的游戏有两种模式,闯关模式,和选关模式,闯关模式不能跳关,必须一关一关的过,选关模式可以选择任意关卡进行游戏。下面是一些程序运行的截图,控制台版本的代码复制后粘贴到编译器可以直接编译运行,我发的代码都是编译通过的,如果有人编译不能通过,可能是用的C语言编译器,改为c++编译器就可以通过了。
上面所说的是第一种控制台程序,下面来说图形界面的程序,可以这样说,第二个图形界面程序是第一个控制台程序的升级版,图形界面的程序在继承第一个控制台程序的所有功能的基础上添加了好多功能,图形界面程序的界面更加好看,而且界面可以在设置里面更换,而且还增加了背景音乐,提示音,动画,等。并且音乐也是可以更换的。所以代码量也大大的增加,差不多有四五千行代码。下面有运行截图,由于代码很长,所以没有发图形界面程序的代码,可以通过链接下载,大约有二十多兆。下载后安装就可以了。点击下面的链接就可以下载图新界面的推箱子游戏。点击链接后,打开压缩包文件夹后可以选择不同版本的压缩包。要图形界面源代码的加我QQ跟我要。---2018年4月21日
更新
3.1.0版本:
1:添加了可以改变程序内文字的字体,总共有六种字体,在设置里可以选择自己喜欢的字体。---2018年4月22日
更新3.1.1版本:
1:3.1.0版本有一些bug,所以又改动了一下。---2018年4月22日
更新3.2.0版本:
1:这个版本添加了商城系统,可以选择喜欢皮肤。
2:此次还添加称号。
3:此次更新增加了对每关数据的保存,比如各个关卡的最少步数。图片我就不发了,欢迎大家下载学习交流。
---2018年4月28日
更新3.3.0版本:
1:这次添加了任务系统,完成任务就可以获得金币。这个任务系统是真的不好写。足足花费我整整两天,我的五一 假期就在敲代码中过去了。唉,马上要考试了,要赶快复习了,不然挂科就不好了。----2018年5月1日
更新3.4.0版本:
1:这次修复了一些bug,添加了一些动画,运用多线程实现一些动画。随着不断的更新,代码越来越长,目前代码 已经超过一万行。下面有控制台版本的源代码,最新图形界面版本的源代码需要加我QQ和我要。---2018年5月6日
更新3.5.0版本:
1:没有什么可说的,下载后自行体会吧。----2018年5月9日
更新4.0.0版本:
1:全新界面,比原先更加好看,附新的截图。----2018年5月24日
更新4.1.0版本:
1:添加每关计时功能,保存最少时间记录。
2:优化操作,优化界面。----2018年5月27日
更新4.3.0版本:
1:4.30.版本支持全屏模式,可以在窗口模式和全屏模式来回互换。
2:修复重置功能错误的BUG。
------2018年6月9日
文件是不断更新的。欢迎大家和我一起学习交流。
源代码下载-->
压缩包下载链接→ 点击打开链接
4.0版本截图
添加两张新的截图
压缩包下载链接→ 点击打开链接
控制台程序运行截图
图形界面程序运行截图
游戏完整源代码:
#include
#include
#include
#include
#include
#include
#define A 2
#define B 6
#define C 5
void gameoperate(int Map[][20],int *n,int *m,int *js,int *sum,int *data,int*sl, int *guanshu,char *ch);
void easygameoperate(int Map[][20],int *n,int *m,int *js,int *sum,int *data,int*sl, int *guanshu,char *ch);
void easyMap(int Map[20][20],int *n,int *m,char *ch);
void middleMap(int Map[20][20],int *n,int *m,char *ch);
void difficultyMap(int Map[][20],int *n,int *m,char *ch);
void selectMap(int Map[][20],int *n,int *m,char *ch,int guan);
void menutwo(char *ch);
void menuone(char *ch);
void menu(char *ch);
int boxdata(int Map[][20],int *n,int *m);
int grounddata(int Map[][20],int *n,int *m);
int DrawMap(int Map[20][20],int *n,int *m,int *guanshu);
void playgame(int Map[20][20],int *n,int *m,char *ch);
void easygame(char *ch);
void middlegame(char *ch);
void difficultygame(char *ch);
void operation(char *ch);
void introduction(char *ch);
void gameintor(char *ch);
int gameready();
void autor(char *ch);
int selectgameready(char *ch,int guan);
void select(char *ch);
void selectgame(char *ch,int guan);
void gotoxy(int x,int y);
void locate(int x,int y);
void password(char *ch);
void hide();
void time();
int data=0;//步数
int *bushu=&data;
int kongge=0;
int *KonGe=&kongge;
int xianshi=0;
int *XianShi=&xianshi;
int yanchi=0;
int *YanChi=&yanchi;
//0:空地,1:墻,3:目的地,4:箱子,5:人
int Map1[8][8]= {{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,4,0,4,3,1},
{1,3,0,4,5,1,1,1},{1,1,1,1,4,1,0,0},{0,0,0,1,3,1,0,0},{0,0,0,1,1,1,0,0}
};
int Map2[9][9]= {{1,1,1,1,1,0,0,0,0},{1,0,0,0,1,0,0,0,0},{1,0,4,4,1,0,1,1,1},{1,5,4,0,1,0,1,3,1},
{1,1,1,0,1,1,1,3,1},{0,1,1,0,0,0,0,3,1},{0,1,0,0,0,1,0,0,1},{0,1,0,0,0,1,1,1,1},{0,1,1,1,1,1,0,0,0}
};
int Map3[7][10]= {{0,1,1,1,1,1,1,1,0,0},{0,1,0,0,0,0,0,1,1,1},{1,1,4,1,1,1,0,0,0,1},{1,5,0,0,4,0,0,4,0,1},
{1,0,3,3,1,0,4,0,1,1},{1,1,3,3,1,0,0,0,1,0},{0,1,1,1,1,1,1,1,1,0}
};
int Map4[8][6]= {{0,1,1,1,1,0},{1,1,0,0,1,0},{1,5,0,4,1,0},{1,1,0,0,1,1},{1,1,4,4,0,1},{1,3,4,0,0,1},
{1,3,3,7,3,1},{1,1,1,1,1,1}
};
int Map5[8][8]= {{0,1,1,1,1,1,0,0},{0,1,0,5,1,1,1,0},{0,1,0,4,0,0,1,0},{1,1,1,0,1,0,1,1},{1,3,1,0,1,0,0,1},
{1,3,4,0,0,1,0,1},{1,3,0,0,0,4,0,1},{1,1,1,1,1,1,1,1}
};
int Map6[11][13]= {{0,0,0,1,1,1,1,1,1,1,0,0,0},{1,1,1,1,0,0,0,0,0,1,0,0,0},{1,0,0,0,3,1,1,1,0,1,0,0,0},
{1,0,1,0,1,0,0,0,0,1,1,0,0},{1,0,1,0,4,0,4,1,3,0,1,0,0},{1,0,1,0,0,7,0,0,1,0,1,0,0},{1,0,3,1,4,0,4,0,1,0,1,0,0},
{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,3,3,3,0,1,4,0,4,0,0,1},{1,1,1,1,1,1,0,0,4,4,0,1},{0,1,1,0,0,4,0,4,4,0,0,1},{0,1,5,0,4,4,4,0,0,1,0,1},
{0,1,1,0,4,0,1,1,0,0,0,1},{0,0,1,0,0,0,0,0,0,0,0,1},{0,0,1,1,1,1,1,1,1,1,1,1}
};
int Map39[10][11]= {{1,1,1,1,1,1,1,1,1,0,0},{1,0,0,0,0,0,0,0,1,0,0},{1,0,0,4,0,4,0,4,1,0,0},{1,1,0,1,4,1,1,0,1,0,0},{0,1,0,3,3,0,3,3,1,1,0},
{0,1,1,3,3,0,3,3,0,1,0},{0,0,1,0,1,1,4,1,0,1,1},{0,0,1,4,0,4,0,4,0,0,1},{0,0,1,0,0,0,0,0,0,5,1},{0,0,1,1,1,1,1,1,1,1,1}
};
int Map40[7][7]= {{1,1,1,1,1,1,1},{1,3,0,3,0,3,1},{1,0,4,4,4,0,1},{1,3,4,5,4,3,1},{1,0,4,4,4,0,1},{1,3,0,3,0,3,1},{1,1,1,1,1,1,1}};
void gotoxy(int x,int y) { //定位光标
COORD pos;
pos.X=x;
pos.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void hide() {//隐藏光标
HANDLE hout =GetStdHandle(STD_OUTPUT_HANDLE);
//COORD coord;
CONSOLE_CURSOR_INFO cursor_info= {1,0};
SetConsoleCursorInfo(hout,&cursor_info);
}
void easyMap(int Map[20][20],int *n,int *m,char *ch) {//简单关卡
static int cs=0;
int guan;
if(*ch=='*') {
guan=cs;
if(guan>0)
guan--;
*ch='!';
} else {
guan=cs;
cs++;
}
//第一关
if(guan==0) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map1[i][j];
*n=sizeof(Map1)/sizeof(Map1[0]);
*m=sizeof(Map1[0])/sizeof(Map1[0][0]);
}
//第二关
else if(guan==1) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map2[i][j];
*n=sizeof(Map2)/sizeof(Map2[0]);
*m=sizeof(Map2[0])/sizeof(Map2[0][0]);
}
//第三关
else if(guan==2) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map3[i][j];
*n=sizeof(Map3)/sizeof(Map3[0]);
*m=sizeof(Map3[0])/sizeof(Map3[0][0]);
}
//第四关
else if(guan==3) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map4[i][j];
*n=sizeof(Map4)/sizeof(Map4[0]);
*m=sizeof(Map4[0])/sizeof(Map4[0][0]);
}
//第五关
else if(guan==4) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map5[i][j];
*n=sizeof(Map5)/sizeof(Map5[0]);
*m=sizeof(Map5[0])/sizeof(Map5[0][0]);
}//第六关
else if(guan==5) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map6[i][j];
*n=sizeof(Map6)/sizeof(Map6[0]);
*m=sizeof(Map6[0])/sizeof(Map6[0][0]);
}
//第七关
else if(guan==6) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map7[i][j];
*n=sizeof(Map7)/sizeof(Map7[0]);
*m=sizeof(Map7[0])/sizeof(Map7[0][0]);
}
//第八关
else if(guan==7) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map8[i][j];
*n=sizeof(Map8)/sizeof(Map8[0]);
*m=sizeof(Map8[0])/sizeof(Map8[0][0]);
}
//第九关
else if(guan==8) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map9[i][j];
*n=sizeof(Map9)/sizeof(Map9[0]);
*m=sizeof(Map9[0])/sizeof(Map9[0][0]);
}
//第十关
else if(guan==9) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map10[i][j];
*n=sizeof(Map10)/sizeof(Map10[0]);
*m=sizeof(Map10[0])/sizeof(Map10[0][0]);
}
}
void middleMap(int Map[20][20],int *n,int *m,char *ch) {//中等关卡
static int cs=0;
int guan;
//fscanf(fp1, "%d", &guanshu2);
//fclose(fp1);//关闭文件
if(*ch=='*') {
guan=cs;
if(guan>0)
guan--;
*ch='!';
} else {
guan=cs;
cs++;
//guan=guanshu2;
//guanshu2++;
}
//第一关
if(guan==0) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map11[i][j];
*n=sizeof(Map11)/sizeof(Map11[0]);
*m=sizeof(Map11[0])/sizeof(Map11[0][0]);
}
//第二关
if(guan==1) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map12[i][j];
*n=sizeof(Map12)/sizeof(Map12[0]);
*m=sizeof(Map12[0])/sizeof(Map12[0][0]);
}
//第三关
if(guan==2) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map13[i][j];
*n=sizeof(Map13)/sizeof(Map13[0]);
*m=sizeof(Map13[0])/sizeof(Map13[0][0]);
}
//第四关
if(guan==3) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map14[i][j];
*n=sizeof(Map14)/sizeof(Map14[0]);
*m=sizeof(Map14[0])/sizeof(Map14[0][0]);
}
//第五关
if(guan==4) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map15[i][j];
*n=sizeof(Map15)/sizeof(Map15[0]);
*m=sizeof(Map15[0])/sizeof(Map15[0][0]);
}
//第六关
if(guan==5) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map16[i][j];
*n=sizeof(Map16)/sizeof(Map16[0]);
*m=sizeof(Map16[0])/sizeof(Map16[0][0]);
}
//第七关
if(guan==6) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map17[i][j];
*n=sizeof(Map17)/sizeof(Map17[0]);
*m=sizeof(Map17[0])/sizeof(Map17[0][0]);
}
//第八关
if(guan==7) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map18[i][j];
*n=sizeof(Map18)/sizeof(Map18[0]);
*m=sizeof(Map18[0])/sizeof(Map18[0][0]);
}
//第九关
if(guan==8) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map19[i][j];
*n=sizeof(Map19)/sizeof(Map19[0]);
*m=sizeof(Map19[0])/sizeof(Map19[0][0]);
}
//第十关
if(guan==9) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map20[i][j];
*n=sizeof(Map20)/sizeof(Map20[0]);
*m=sizeof(Map20[0])/sizeof(Map20[0][0]);
}
/*
fp1 = fopen("test2.txt","w");
fprintf(fp1, "%d\n",guan);
fclose(fp1);
*/
}
void difficultyMap(int Map[][20],int *n,int *m,char *ch) {//困难关卡
static int css=0;
int guan;
if(*ch=='*') {
guan=css;
if(guan>0)
guan--;
*ch='!';
} else {
guan=css;
css++;
}
//第一关
if(guan==0) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map21[i][j];
*n=sizeof(Map21)/sizeof(Map21[0]);
*m=sizeof(Map21[0])/sizeof(Map21[0][0]);
}
//第二关
if(guan==1) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map22[i][j];
*n=sizeof(Map22)/sizeof(Map22[0]);
*m=sizeof(Map22[0])/sizeof(Map22[0][0]);
}
//第三关
if(guan==2) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map23[i][j];
*n=sizeof(Map23)/sizeof(Map23[0]);
*m=sizeof(Map23[0])/sizeof(Map23[0][0]);
}
//第四关
if(guan==3) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map24[i][j];
*n=sizeof(Map24)/sizeof(Map24[0]);
*m=sizeof(Map24[0])/sizeof(Map24[0][0]);
}
//第五关
if(guan==4) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map25[i][j];
*n=sizeof(Map25)/sizeof(Map25[0]);
*m=sizeof(Map25[0])/sizeof(Map25[0][0]);
}
//第六关
if(guan==5) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map26[i][j];
*n=sizeof(Map26)/sizeof(Map26[0]);
*m=sizeof(Map26[0])/sizeof(Map26[0][0]);
}
//第七关
if(guan==6) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map27[i][j];
*n=sizeof(Map27)/sizeof(Map27[0]);
*m=sizeof(Map27[0])/sizeof(Map27[0][0]);
}
//第八关
if(guan==7) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map28[i][j];
*n=sizeof(Map28)/sizeof(Map28[0]);
*m=sizeof(Map28[0])/sizeof(Map28[0][0]);
}
//第九关
if(guan==8) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map29[i][j];
*n=sizeof(Map29)/sizeof(Map29[0]);
*m=sizeof(Map29[0])/sizeof(Map29[0][0]);
}
//第十关
if(guan==9) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map30[i][j];
*n=sizeof(Map30)/sizeof(Map30[0]);
*m=sizeof(Map30[0])/sizeof(Map30[0][0]);
}
//十一关
if(guan==10) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map31[i][j];
*n=sizeof(Map31)/sizeof(Map31[0]);
*m=sizeof(Map31[0])/sizeof(Map3[0][0]);
}
//十二关
if(guan==11) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map32[i][j];
*n=sizeof(Map32)/sizeof(Map32[0]);
*m=sizeof(Map32[0])/sizeof(Map32[0][0]);
}
//十三关
if(guan==12) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map33[i][j];
*n=sizeof(Map33)/sizeof(Map33[0]);
*m=sizeof(Map33[0])/sizeof(Map33[0][0]);
}
//十四关
if(guan==13) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map34[i][j];
*n=sizeof(Map34)/sizeof(Map34[0]);
*m=sizeof(Map34[0])/sizeof(Map34[0][0]);
}
//十五关
if(guan==14) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map35[i][j];
*n=sizeof(Map35)/sizeof(Map35[0]);
*m=sizeof(Map35[0])/sizeof(Map35[0][0]);
}
//十六关
if(guan==15) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map36[i][j];
*n=sizeof(Map36)/sizeof(Map36[0]);
*m=sizeof(Map36[0])/sizeof(Map36[0][0]);
}
//十七关
if(guan==16) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map37[i][j];
*n=sizeof(Map37)/sizeof(Map37[0]);
*m=sizeof(Map37[0])/sizeof(Map37[0][0]);
}
//十八关
if(guan==17) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map38[i][j];
*n=sizeof(Map38)/sizeof(Map38[0]);
*m=sizeof(Map38[0])/sizeof(Map38[0][0]);
}
//十九关
if(guan==18) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map39[i][j];
*n=sizeof(Map39)/sizeof(Map39[0]);
*m=sizeof(Map39[0])/sizeof(Map39[0][0]);
}
//二十关
if(guan==19) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map40[i][j];
*n=sizeof(Map40)/sizeof(Map40[0]);
*m=sizeof(Map40[0])/sizeof(Map40[0][0]);
}
/*
fp2 = fopen("test3.txt","w");
fprintf(fp2, "%d\n",guan);
fclose(fp2);
*/
}
void selectMap(int Map[][20],int *n,int *m,char *ch,int guan) {//选关地图
guan--;
//第一关
if(guan==0) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map1[i][j];
*n=sizeof(Map1)/sizeof(Map1[0]);
*m=sizeof(Map1[0])/sizeof(Map1[0][0]);
}
//第二关
else if(guan==1) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map2[i][j];
*n=sizeof(Map2)/sizeof(Map2[0]);
*m=sizeof(Map2[0])/sizeof(Map2[0][0]);
}
//第三关
else if(guan==2) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map3[i][j];
*n=sizeof(Map3)/sizeof(Map3[0]);
*m=sizeof(Map3[0])/sizeof(Map3[0][0]);
}
//第四关
else if(guan==3) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map4[i][j];
*n=sizeof(Map4)/sizeof(Map4[0]);
*m=sizeof(Map4[0])/sizeof(Map4[0][0]);
}
//第五关
else if(guan==4) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map5[i][j];
*n=sizeof(Map5)/sizeof(Map5[0]);
*m=sizeof(Map5[0])/sizeof(Map5[0][0]);
}//第六关
else if(guan==5) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map6[i][j];
*n=sizeof(Map6)/sizeof(Map6[0]);
*m=sizeof(Map6[0])/sizeof(Map6[0][0]);
}
//第七关
else if(guan==6) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map7[i][j];
*n=sizeof(Map7)/sizeof(Map7[0]);
*m=sizeof(Map7[0])/sizeof(Map7[0][0]);
}
//第八关
else if(guan==7) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map8[i][j];
*n=sizeof(Map8)/sizeof(Map8[0]);
*m=sizeof(Map8[0])/sizeof(Map8[0][0]);
}
//第九关
else if(guan==8) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map9[i][j];
*n=sizeof(Map9)/sizeof(Map9[0]);
*m=sizeof(Map9[0])/sizeof(Map9[0][0]);
}
//第十关
else if(guan==9) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map10[i][j];
*n=sizeof(Map10)/sizeof(Map10[0]);
*m=sizeof(Map10[0])/sizeof(Map10[0][0]);
}
//第十一关
else if(guan==10) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map11[i][j];
*n=sizeof(Map11)/sizeof(Map11[0]);
*m=sizeof(Map11[0])/sizeof(Map11[0][0]);
}
//第十二关
else if(guan==11) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map12[i][j];
*n=sizeof(Map12)/sizeof(Map12[0]);
*m=sizeof(Map12[0])/sizeof(Map12[0][0]);
}
//第十三关
else if(guan==12) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map13[i][j];
*n=sizeof(Map13)/sizeof(Map13[0]);
*m=sizeof(Map13[0])/sizeof(Map13[0][0]);
}
//第十四关
else if(guan==13) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map14[i][j];
*n=sizeof(Map14)/sizeof(Map14[0]);
*m=sizeof(Map14[0])/sizeof(Map14[0][0]);
}
//第十五关
else if(guan==14) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map15[i][j];
*n=sizeof(Map15)/sizeof(Map15[0]);
*m=sizeof(Map15[0])/sizeof(Map15[0][0]);
}
//第十六关
else if(guan==15) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map16[i][j];
*n=sizeof(Map16)/sizeof(Map16[0]);
*m=sizeof(Map16[0])/sizeof(Map16[0][0]);
}
//第十七关
else if(guan==16) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map17[i][j];
*n=sizeof(Map17)/sizeof(Map17[0]);
*m=sizeof(Map17[0])/sizeof(Map17[0][0]);
}
//第十八关
else if(guan==17) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map18[i][j];
*n=sizeof(Map18)/sizeof(Map18[0]);
*m=sizeof(Map18[0])/sizeof(Map18[0][0]);
}
//第十九关
else if(guan==18) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map19[i][j];
*n=sizeof(Map19)/sizeof(Map19[0]);
*m=sizeof(Map19[0])/sizeof(Map19[0][0]);
}
//第二十关
else if(guan==19) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map20[i][j];
*n=sizeof(Map20)/sizeof(Map20[0]);
*m=sizeof(Map20[0])/sizeof(Map20[0][0]);
}
//第二十一关
else if(guan==20) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map21[i][j];
*n=sizeof(Map21)/sizeof(Map21[0]);
*m=sizeof(Map21[0])/sizeof(Map21[0][0]);
}
//第二十二关
else if(guan==21) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map22[i][j];
*n=sizeof(Map22)/sizeof(Map22[0]);
*m=sizeof(Map22[0])/sizeof(Map22[0][0]);
}
//第二十三关
else if(guan==22) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map23[i][j];
*n=sizeof(Map23)/sizeof(Map23[0]);
*m=sizeof(Map23[0])/sizeof(Map23[0][0]);
}
//第二十四关
else if(guan==23) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map24[i][j];
*n=sizeof(Map24)/sizeof(Map24[0]);
*m=sizeof(Map24[0])/sizeof(Map24[0][0]);
}
//第二十五关
else if(guan==24) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map25[i][j];
*n=sizeof(Map25)/sizeof(Map25[0]);
*m=sizeof(Map25[0])/sizeof(Map25[0][0]);
}
//第二十六关
else if(guan==25) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map26[i][j];
*n=sizeof(Map26)/sizeof(Map26[0]);
*m=sizeof(Map26[0])/sizeof(Map26[0][0]);
}
//第二十七关
else if(guan==26) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map27[i][j];
*n=sizeof(Map27)/sizeof(Map27[0]);
*m=sizeof(Map27[0])/sizeof(Map27[0][0]);
}
//第二十八关
else if(guan==27) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map28[i][j];
*n=sizeof(Map28)/sizeof(Map28[0]);
*m=sizeof(Map28[0])/sizeof(Map28[0][0]);
}
//第二十九关
if(guan==28) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map29[i][j];
*n=sizeof(Map29)/sizeof(Map29[0]);
*m=sizeof(Map29[0])/sizeof(Map29[0][0]);
}
//第三十关
if(guan==29) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map30[i][j];
*n=sizeof(Map30)/sizeof(Map30[0]);
*m=sizeof(Map30[0])/sizeof(Map30[0][0]);
}
//三十一关
if(guan==30) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map31[i][j];
*n=sizeof(Map31)/sizeof(Map31[0]);
*m=sizeof(Map31[0])/sizeof(Map3[0][0]);
}
//三十二关
if(guan==31) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map32[i][j];
*n=sizeof(Map32)/sizeof(Map32[0]);
*m=sizeof(Map32[0])/sizeof(Map32[0][0]);
}
//三十三关
if(guan==32) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map33[i][j];
*n=sizeof(Map33)/sizeof(Map33[0]);
*m=sizeof(Map33[0])/sizeof(Map33[0][0]);
}
//三十四关
if(guan==33) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map34[i][j];
*n=sizeof(Map34)/sizeof(Map34[0]);
*m=sizeof(Map34[0])/sizeof(Map34[0][0]);
}
//三十五关
if(guan==34) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map35[i][j];
*n=sizeof(Map35)/sizeof(Map35[0]);
*m=sizeof(Map35[0])/sizeof(Map35[0][0]);
}
//三十六关
if(guan==35) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map36[i][j];
*n=sizeof(Map36)/sizeof(Map36[0]);
*m=sizeof(Map36[0])/sizeof(Map36[0][0]);
}
//三十七关
if(guan==36) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map37[i][j];
*n=sizeof(Map37)/sizeof(Map37[0]);
*m=sizeof(Map37[0])/sizeof(Map37[0][0]);
}
//三十八关
if(guan==37) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map38[i][j];
*n=sizeof(Map38)/sizeof(Map38[0]);
*m=sizeof(Map38[0])/sizeof(Map38[0][0]);
}
//三十九关
if(guan==38) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map39[i][j];
*n=sizeof(Map39)/sizeof(Map39[0]);
*m=sizeof(Map39[0])/sizeof(Map39[0][0]);
}
//四十关
if(guan==39) {
for(unsigned int i=0; i for(unsigned int j=0; j Map[i][j]=Map40[i][j];
*n=sizeof(Map40)/sizeof(Map40[0]);
*m=sizeof(Map40[0])/sizeof(Map40[0][0]);
}
}
void menutwo(char *ch) {//菜单二
while(1) {
system("cls");
hide();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN | FOREGROUND_RED |FOREGROUND_BLUE|FOREGROUND_INTENSITY);
int s;
printf("\n\n\n\n\n\n\n");
printf(" ------------------------------------\n\n");
printf("\t\t (1):简单关卡\n\n");
printf("\t\t (2):中等关卡\n\n");
printf("\t\t (3):困难关卡\n\n");
printf("\t\t (4):退出页面\n\n");
printf(" ------------------------------------\n\n");
printf("\t\t 请输入序号。\n");
s=getch();
while(s<'1'||s>'4') {
printf("输入有误,请重新输入:");
s=getch();
}
if(s=='1')
easygame(ch);
else if(s=='2')
middlegame(ch);
else if(s=='3')
difficultygame(ch);
else if(s=='4')
menuone(ch);
}
}
void autor(char *ch) {//作者。。。
char hh='!';
system("cls");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
printf("\n\n\n\n");
printf(" 此游戏非常简陋,虽然我(尔灵尔亿)已经非常努力了,");
printf("花费我了几天的时间,写这个游戏纯属娱乐和学习,也纯属巧合。");
printf("之所以要写是因为凑巧从网上看到一个用C语言写推箱子的方法,");
printf("所以自己就有了一个写一个推箱子的小游戏的想法。经过几天的时间");
printf("终于写出一个非常简易的推箱子小游戏(这个小游戏现在写了有五十多关了),期间出现的BUG无群无尽,自己是改了又改,");
printf("到现在为止,肯定是还有好多BUG。通过写这个推箱子小游戏,让我知道了,做一个游戏");
printf("是多么的难,看这个如此简陋的小游戏,也足足有一千百多行的代码。\n");
printf(" 啊啊啊,又几天了,好烦,按键闪屏的问题真的好麻烦,一直解决不了,太痛苦了,");
printf("还好用 W S A D 四个键闪屏问题不是太严重。");
printf("百度一下说什么双缓冲,换成用gotoxy()函数,才能解决闪屏问题,好吧根本不会,能力太低了。唉,就这样吧。\n");
printf(" 版本1.0,只有一个地图,什么都没有。版本1.1,添加了判断通关的功能。版本1.2,增加了多个关卡,修复了多个BUG。");
printf("版本2.0,添加界面,以及各种模式。版本2.1,再次增加关卡,关卡数到达50关。版本2.2,添加了地图中不同物品以及文字显示不同颜色。");
printf("版本2.3,增加记录移动步数的功能,修复许多BUG。版本2.4.0,优化了界面。版本2.4.1,修复了在选关模式下记录步数不能重置的问题。");
printf("版本2.6.1,修复输入密码不能删除的问题。2.6.5版本修复一些BUG。\n\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN|FOREGROUND_INTENSITY);
printf("\t\t 退出请按 键。\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_INTENSITY);
gotoxy(28,27);
printf("ESC");
hh=getch();
if(hh==27)
introduction(ch);
}
void menu(char *ch) {//主菜单
while(1) {
system("cls");
hide();
int s;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN | FOREGROUND_RED |FOREGROUND_BLUE|FOREGROUND_INTENSITY);
printf("\n\n\n\n\n\t 主 菜 单\n\n");
printf("\n\n\t\t 推箱子\n\n");
printf(" ------------------------------------\n\n");
printf("\t\t (1):开始游戏\n\n");
printf("\t\t (2):操作介绍\n\n");
printf("\t\t (3):游戏介绍\n\n");
printf("\t\t (4):退出游戏\n\n");
printf(" ------------------------------------\n\n");
printf("****************第一次请先观看操作介绍****************\n\n");
printf("\t\t 请输入序号。\n");
s=getch();
while(s<'1'||s>'4') {
printf("\t\t输入有误,请重新输入。\n");
s=getch();
}
if(s=='1')
menuone(ch);
else if(s=='2')
operation(ch);
else if(s=='3')
introduction(ch);
else {
int i=MessageBox(NULL,"\n确定要退出游戏吗?","退出提示",MB_YESNO);
if(i==IDYES)
exit(0);
}
}
}
void menuone(char *ch) {//菜单一
while(1) {
system("cls");
hide();
int s;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN | FOREGROUND_RED |FOREGROUND_BLUE|FOREGROUND_INTENSITY);
printf("\n\n\n\n\n\n\n");
printf(" ------------------------------------\n\n");
printf("\t\t (1):闯关模式\n\n");
printf("\t\t (2):选关模式\n\n");
printf("\t\t (3):退出页面\n\n");
printf(" ------------------------------------\n\n");
printf("\t\t 请输入序号。\n");
s=getch();
while(s<'1'||s>'3') {
printf("\t\t输入有误,请重新输入。\n");
s=getch();
}
if(s=='1')
menutwo(ch);
else if(s=='2')
select(ch);
else
menu(ch);
}
}
void select(char *ch) { //选关
system("cls");
int guan;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN | FOREGROUND_RED |FOREGROUND_BLUE|FOREGROUND_INTENSITY);
printf("\n\n\n\n\n\n\n\n\n");
printf("\t\t\t 请\n\n\t\t\t 输入\n\n\t\t\t 所要选择\n\n\t\t 的关卡(1-40关),\n\n\t\t 输入0回退到前一\n\n\t\t 页面。之后按回车键:");
scanf("%d",&guan);
while(guan<0||guan>40) {
printf("\t\t输入有误,请重新输入。\n");
scanf("%d",&guan);
}
if(guan==0)
menuone(ch);
selectgameready(ch,guan);
}
void selectgame(char *ch,int guan) {
int Map[20][20],n,m;
memset(Map,-1,sizeof(Map));
int sum=0,data=0,sl=0;
while(1) {
selectMap(Map,&n,&m,ch,guan);
data=boxdata(Map,&n,&m);
sl=grounddata(Map,&n,&m);
while(1) {
system("cls");//清屏
sum=DrawMap(Map,&n,&m,&guan);//画图
sum-=sl;
if(sum==data) {
hide();//隐藏光标
printf("\n\t\t 恭 喜 通 关!\n\n");
printf("\t 请稍等,正在重置关卡。\n");
time();
break;
}
playgame(Map,&n,&m,ch);//操作函数
if(*ch=='*') {
*bushu=0;
//*XianShi=1;
break;
}
}
if(*ch=='*') {
*ch='!';
break;
}
}
}
int selectgameready(char *ch,int guan) {//游戏准备
while(1) {
system("cls");
hide();
int s;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN | FOREGROUND_RED |FOREGROUND_BLUE|FOREGROUND_INTENSITY);
printf("\n\n\n\n\n\n\n");
printf(" ------------------------------------\n\n");
printf("\t\t (1):游戏开始\n\n");
printf("\t\t (2):游戏退出\n\n");
printf(" ------------------------------------\n\n");
printf("\t\t 请输入序号。\n");
s=getch();
while(s!='1'&&s!='2') {
printf("\t\t输入有误,请重新输入。\n");
s=getch();
}
if(s=='1')
selectgame(ch,guan);
else
select(ch);
}
return 0;
}
void password(char *ch) {//密码输入判断
char passwords[10],Passwords[10]= {"123456789"};
while(1) {
system("cls");
printf("\n\n\n\n\n\n\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN | FOREGROUND_RED |FOREGROUND_BLUE|FOREGROUND_INTENSITY);
printf(" 说明:\n\t 输入密码后按回车键。\n\n");
printf(" ------------------------------------\n\n");
printf("\t\t (1):输入密码\n\n");
printf("\t\t (2):退出页面\n\n");
printf(" ------------------------------------\n\n");
printf("\t\t 输入序号\n\n");
//printf("\n\n\n");
int t=getch();
if(t=='1') {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);//红色
printf("\t\t密码:");
int i;
for(i=0; i<100; i++) {
passwords[i]=getch();
if(passwords[i]==8){
i-=2;
printf("\b \b");
}
else if(passwords[i]=='\r')
break;
else
printf("*");
}
passwords[i]='\0';
if(strcmp(passwords,Passwords)==0)
break;
else
MessageBox(NULL,"\t 密码错误!!!\t\n\t请重新输入密码。\t","输入提示",MB_OK);
}
else
introduction(ch);
}
}
void introduction(char *ch) {
system("cls");
hide();
int s;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN | FOREGROUND_RED |FOREGROUND_BLUE|FOREGROUND_INTENSITY);//白色
printf("\n\n\n\n\n\n\n");
printf(" ------------------------------------\n\n");
printf("\t\t (1):游戏名称:推箱子\n\n");
printf("\t\t (2):游戏简介:->(next)\n\n");
printf("\t\t (3):完成日期:2018年3月\n\n");
printf("\t\t (4):作者:尔灵尔亿->(next)\n\n");
printf("\t\t (5):QQ:2117610943\n\n");
printf("\t\t (6):版本:%d.%d.%d\n\n",A,B,C);
printf("\t\t (7):退出页面\n\n");
printf(" ------------------------------------\n\n");
printf("\t\t 请输入序号。\n");
s=getch();
while(s!='2'&&s!='7'&&s!='4') {
printf("\t\tSorry,此序号没有下一页了。\n");
s=getch();
}
if(s=='2')
gameintor(ch);
else if(s=='7')
menu(ch);
else if(s=='4') {
MessageBox(NULL,"\t 请输入密码。\t\n\t(少于十个数字或字母)\t","输入提示",MB_OK);
password(ch);
autor(ch);
}
}
void gameintor(char *ch) {//游戏介绍
while(1) {
system("cls");
hide();
char hh='!';
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN | FOREGROUND_RED |FOREGROUND_INTENSITY);//红色
printf("\n\n\n\n\n");
printf(" 《推箱子》是一款经典电子游戏,1982年由日本Thinking Rabbit公司首次发行");
printf("之后其他游戏开发者争相制作仿制或衍生作品。致使推箱子成为此类游戏的代名词。");
printf("游戏要求玩家在一个狭小的仓库中,要求把木箱放到指定的位置,稍不小心就会出现");
printf("t箱子无法移动或者通道被堵住的情况,所以需要巧妙的利用有限的空间和通道,合理");
printf("t安排移动的次序和位置,才能顺利的完成任务。 \n");
printf(" 推箱子是一个来自日本的古老游戏,目的是在训练玩家的逻辑思考能力。在一个狭");
printf("小的仓库中,要求把木箱放到指定的位置,稍不小心就会出现箱子无法移动或者通道被堵");
printf("住的情况,所以需要巧妙的利用有限的空间和通道,合理安排移动的次序和位置,才能顺");
printf("利的完成任务。\n\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_INTENSITY);
printf(" 注:游戏关卡来源于经典推箱子关卡。\n\n\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN|FOREGROUND_INTENSITY);
printf("\t\t 退出请按 键。\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
gotoxy(26,21);
printf("ESC");
hh=getch();
if(hh==27)
introduction(ch);
}
}
void operation(char *ch) {//操作介绍
char hh='!';
while(1) {
system("cls");
hide();
printf("\n\n\n\n\n\n\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
printf("\t\t\t操作说明:\n\n\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);//红色
printf(" (W):向上移动 (S):向下移动 (A):向左移动 (D):向右移动\n\n");
printf(" (□):代表箱子 (♀):代表人 (☆):代表目的地\n\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
printf("\t *按键盘前请调整好输入法。\n\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_GREEN);
printf("\t\t 退出请按 键。\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
gotoxy(29,16);
printf("ESC");
hh=getch();
if(hh==27)
menu(ch);
}
}
int boxdata(int Map[][20],int *n,int *m) {//计算箱子数
int sum=0;
for(int i=0; i<*n; i++) {
for(int j=0; j<*m; j++) {
if(Map[i][j]==3)
sum++;
}
}
return sum;
}
int grounddata(int Map[][20],int *n,int *m) {//计算箱子开始时就在目的地的数目
int sum=0;
for(int i=0; i<*n; i++) {
for(int j=0; j<*m; j++) {
if(Map[i][j]==7)
sum++;
}
}
return sum;
}
int DrawMap(int Map[20][20],int *n,int *m,int *guanshu) {//画出地图
int sum=0;
hide();
printf("\n\n\n\n\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
printf("\t\t 第 %d 关\n\n\n\n",*guanshu);
for(int i=0; i<*n; i++) {
printf("\t\t ");
for(int j=0; j<*m; j++) {
switch(Map[i][j]) {
case 1://墻
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);//改变颜色函数
printf("■");
break;
case 0://空地
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
printf(" ");
break;
case 3://目的地
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
printf("☆");
break;
case 4://箱子
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_RED);
printf("□");
break;
case 5://人
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
printf("♀");
break;
case 7://箱子在目的地 4+3
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
printf("★");
sum++;
break;
case 8://人在目的地 5+3
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
printf("♀");
break;
}
}
printf("\n");
}
if(kongge==1) {
printf("\n\t\t 当前步数为%d步。",*bushu);
if(yanchi==10) {
*KonGe=0;
*YanChi=0;
}
yanchi++;
xianshi=1;
}
if(xianshi==0) {
printf("\n\t\t 按空格键查看当前步数。");
}
*XianShi=0;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN |FOREGROUND_INTENSITY);
printf("\n 按ESC键退出此游戏,之后重新进入从该关重新开始。\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_INTENSITY);
printf("\n\t 开始游戏前输入法请锁定成英文大写。\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN | FOREGROUND_RED |FOREGROUND_INTENSITY);
gotoxy(12,23);
printf("W/↑:上移");
gotoxy(32,23);
printf("S/↓:下移");
gotoxy(12,25);
printf("A/←:左移");
gotoxy(32,25);
printf("D/→:右移");
return sum;
}
void playgame(int Map[20][20],int *n,int *m,char *ch) {//游戏控制/*************这个是最重要的**************/
char input;
int i,j;
//确定人的位置
for(i=0; i<*n; i++) {
for(j=0; j<*m; j++) {
if(Map[i][j]==5||Map[i][j]==8)
break;
}
if(Map[i][j]==5||Map[i][j]==8)
break;
}
input=getch();//头文件conio.h
switch(input) {
case 72:
case 'W'://上
case 'w':
if(Map[i-1][j]==0||Map[i-1][j]==3) {//人前面是空地或者人前面是目的地
Map[i-1][j]+=5;
Map[i][j]-=5;
data++;
} else if(Map[i-1][j]==4||Map[i-1][j]==7) {//人的前面是箱子的情况
if(Map[i-2][j]==0||Map[i-2][j]==3) {
Map[i-2][j]+=4;
Map[i-1][j]+=1;
Map[i][j]-=5;
data++;
}
}
break;
case 80:
case 'S'://下
case 's':
if(Map[i+1][j]==0||Map[i+1][j]==3) {//人前面是空地或者人前面是目的地
Map[i+1][j]+=5;
Map[i][j]-=5;
data++;
} else if(Map[i+1][j]==4||Map[i+1][j]==7) {//人的前面是箱子的情况
if(Map[i+2][j]==0||Map[i+2][j]==3) {
Map[i+2][j]+=4;
Map[i+1][j]+=1;
Map[i][j]-=5;
data++;
}
}
break;
case 75:
case 'A'://左
case 'a':
if(Map[i][j-1]==0||Map[i][j-1]==3) {//人前面是空地或者人前面是目的地
Map[i][j-1]+=5;
Map[i][j]-=5;
data++;
} else if(Map[i][j-1]==4||Map[i][j-1]==7) {//人的前面是箱子的情况
if(Map[i][j-2]==0||Map[i][j-2]==3) {
Map[i][j-2]+=4;
Map[i][j-1]+=1;
Map[i][j]-=5;
data++;
}
}
break;
case 77:
case 'D'://右
case 'd':
if(Map[i][j+1]==0||Map[i][j+1]==3) {//人前面是空地或者人前面是目的地
Map[i][j+1]+=5;
Map[i][j]-=5;
data++;
} else if(Map[i][j+1]==4||Map[i][j+1]==7) {//人的前面是箱子的情况
if(Map[i][j+2]==0||Map[i][j+2]==3) {
Map[i][j+2]+=4;
Map[i][j+1]+=1;
Map[i][j]-=5;
data++;
}
}
break;
case 27:
*ch='*';
break;
case 32:
*KonGe=1;
break;
}
}
void time() {//倒计时
int t=0;
for(int i=9; i>=0; i--) {
Sleep(500);
gotoxy(25,23);
if(t==3)
t=0;
if(t==0)
printf("%d. ",i);
else if(t==1)
printf("%d.. ",i);
else
printf("%d...",i);
t++;
}
}
int gameready() {//游戏准备
system("cls");
hide();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN | FOREGROUND_RED |FOREGROUND_BLUE|FOREGROUND_INTENSITY);//白色
int s;
printf("\n\n\n\n\n\n\n");
printf(" ------------------------------------\n\n");
printf("\t\t (1):游戏开始\n\n");
printf("\t\t (2):游戏退出\n\n");
printf(" ------------------------------------\n\n");
printf("\t\t 请输入序号。\n");
s=getch();
while(s!='1'&&s!='2') {
printf("\t\t输入有误,请重新输入。\n");
s=getch();
}
return s;
}
void gameoperate(int Map[][20],int *n,int *m,int *js,int *sum,int *data,int*sl, int *guanshu,char *ch) {//游戏函数调用
while(1) {
clock_t start,end;
start=clock();
*js=0;
system("cls");//清屏
hide();
*sum=DrawMap(Map,n,m,guanshu);//画图
*sum-=*sl;
if(*sum==*data) {
system("cls");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED |FOREGROUND_INTENSITY);
printf("\n\n\n\n\n\n\n\n\n\n\n\t\t 恭 喜 通 关!\n\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN |FOREGROUND_INTENSITY);
printf("\n\t\t 通关所用步数为%d步。\n\n",*bushu);
end=clock();
printf("\n\t 通关所用时间为%.3lf秒\n\n",(double)(end-start)/9.56);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_BLUE |FOREGROUND_INTENSITY);
printf("\n\t 请稍等,正在创建下一关。\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED |FOREGROUND_INTENSITY);
time();
*bushu=0;
break;
}
playgame(Map,n,m,ch);//操作函数
if(*ch=='*') {
int i=MessageBox(NULL,"\t\n确定要退出游戏吗?\n\n(提示:退出后重新进入从退出的关卡开始)。","退出提示",MB_YESNO);
if(i==IDYES) {
*bushu=0;
*XianShi=1;
*js=1;
break;
} else {
*ch='!';
continue;
}
}
}
}
void easygameoperate(int Map[][20],int *n,int *m,int *js,int *sum,int *data,int*sl, int *guanshu,char *ch) {//游戏函数调用
while(1) {
*js=0;
system("cls");//清屏
hide();
*sum=DrawMap(Map,n,m,guanshu);//画图
*sum-=*sl;
if(*sum==*data) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED |FOREGROUND_INTENSITY);
printf("\t\t\t\t 恭 喜 通 关!\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED |FOREGROUND_INTENSITY);
int t=MessageBox(NULL,"\t 你真棒!!!\n\n\t是否进入下一关?","提示",MB_YESNO);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN |FOREGROUND_INTENSITY);
printf("\t\t 通关所用步数为%d步。\n",*bushu);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_BLUE |FOREGROUND_INTENSITY);
printf("\t 请稍等,正在创建下一关。");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED |FOREGROUND_INTENSITY);
time();
if(t==IDYES) {
*bushu=0;
break;
} else {
*bushu=0;
*XianShi=1;
*js=2;
break;
}
}
playgame(Map,n,m,ch);//操作函数
if(*ch=='*') {
int i=MessageBox(NULL,"\t\n确定要退出游戏吗?\n\n(提示:退出后重新进入从退出的关卡开始)。","退出提示",MB_YESNO);
if(i==IDYES) {
*bushu=0;
*XianShi=1;
*js=1;
break;
} else {
*ch='!';
continue;
}
}
}
}
void easygame(char *ch) {//简单关卡控制
int Map[20][20],n,m,js;
static int guanshu=1;
memset(Map,-1,sizeof(Map));
int sum=0,data=0,sl=0;
while(1) {
int t=gameready();
if(t=='2')
break;
while(1) {
easyMap(Map,&n,&m,ch);
data=boxdata(Map,&n,&m);
sl=grounddata(Map,&n,&m);
easygameoperate(Map,&n,&m,&js,&sum,&data,&sl,&guanshu,ch);
int s;
if(js==0) {
guanshu++;
if(guanshu<11)
s=1;
else {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED |FOREGROUND_INTENSITY);
printf("恭喜你已经通过全部简单关卡,接下来有中等关卡等待你去挑战\n");
gotoxy(19,26);
printf("!!!!!!");
}
} else if(js==1)
break;
else if(js==2) {
*ch='*';
continue;
}
if(s=='2')
break;
}
}
}
void middlegame(char *ch) {//中等关卡控制
int Map[20][20],n,m,js;
static int guanshu=1;
memset(Map,-1,sizeof(Map));
int sum=0,data=0,sl=0;
while(1) {
int t=gameready();
if(t=='2')
break;
while(1) {
middleMap(Map,&n,&m,ch);
data=boxdata(Map,&n,&m);
sl=grounddata(Map,&n,&m);
gameoperate(Map,&n,&m,&js,&sum,&data,&sl,&guanshu,ch);
int s;
if(js==0) {
guanshu++;
if(guanshu<11)
s=1;
else {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED |FOREGROUND_INTENSITY);
printf("恭喜你已经通过全部中等关卡,接下来有困难关卡等待你去挑战\n");
gotoxy(19,26);
printf("!!!!!!");
}
} else if(js==1)
break;
if(s=='2')
break;
}
}
}
void difficultygame(char *ch) {//困难关卡控制
/*
int Map[20][20],n,m,js;
static int guanshu=1;
memset(Map,-1,sizeof(Map));
int sum=0,data=0,sl=0;
while(1) {
int t=gameready();
if(t=='2')
break;
while(1) {
difficultyMap(Map,&n,&m,ch);
data=boxdata(Map,&n,&m);
sl=grounddata(Map,&n,&m);
gameoperate(Map,&n,&m,&js,&sum,&data,&sl,&guanshu,ch);
int s;
if(js==0) {
guanshu++;
if(guanshu<11)
s=1;
else {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED |FOREGROUND_INTENSITY);
printf("恭喜你已经通过全部关卡!\n");
gotoxy(19,26);
printf("!!!!!!");
}
} else if(js==1)
break;
if(s=='2')
break;
}
}
*/
int Map[20][20],n,m,js;
static int guanshu=1;
memset(Map,-1,sizeof(Map));
int sum=0,data=0,sl=0;
while(1) {
int t=gameready();
if(t=='2')
break;
while(1) {
difficultyMap(Map,&n,&m,ch);
data=boxdata(Map,&n,&m);
sl=grounddata(Map,&n,&m);
easygameoperate(Map,&n,&m,&js,&sum,&data,&sl,&guanshu,ch);
int s;
if(js==0) {
guanshu++;
if(guanshu<21)
s=1;
else {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED |FOREGROUND_INTENSITY);
printf("恭喜你已经通过全部关卡!\n");
gotoxy(19,26);
printf("!!!!!!");
}
} else if(js==1)
break;
else if(js==2) {
*ch='*';
continue;
}
if(s=='2')
break;
}
}
}
int main() {//主函数
char ch='!';
system("title 推箱子C语言2.6.5版---尔灵尔亿制作");//设置标题
system("mode con cols=55 lines=30");//控制窗口大小
while(1) {
system("cls");//清除屏幕
hide();
menu(&ch);//菜单一
}
return 0;
}