一 二维数组指定对象的位置和种类。
二 双缓存消除屏幕闪烁。
三 核心代码 switch语句计算出字符的逻辑变化。
有了思路,代码就容易写了,下面是界面图:
十八关图,好多箱子,眼都花了,对得起推箱仙人的称号:
主程序代码:
/********************************
名称:推箱子
描述:用控制台程序实现推箱子小游戏
编译:codeblocks16.01 vs2010
创建:零千刻
日期:170502
*********************************/
#include
#include
#include
#include
extern int map1[14][16], map2[14][16], map3[14][16], map4[14][16],map5[14][16],
map6[14][16], map7[14][16], map8[14][16],map9[14][16], map10[14][16],
map11[14][16], map12[14][16],map13[14][16], map14[14][16], map15[14][16],
map16[14][16],map17[14][16], map18[14][16];
void DrawMap();
void PlayGame();
void TextManage();
void DrawMapBase();
void nextMap();
void TextChange();
void stopFlash();
HANDLE hOutput;
HANDLE hOutBuf;
COORD coord= {0,0}; //COORD是Windows API中定义的一种结构,表示一个字符在控制台屏幕上的坐标。
int stra=strlen("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
int map[14][16]= {};
bool mapNumWait=true;//地图关卡数
int mapNumGoing=1;//地图关卡数
int mapNumGoingC=1;//地图关卡数副本
bool nextm=true;
bool textc=false;
bool nextK=true;
int iox=0;
int jox=0;
char data[720];//控制台默认一行为80个半角字符,
DWORD bytes=0;
int main()
{
//获取默认标准显示缓冲区句柄
hOutput=GetStdHandle(STD_OUTPUT_HANDLE);
// 获取标准输出设备句柄
//CONSOLE_SCREEN_BUFFER_INFO bInfo; // 窗口缓冲区信息
//GetConsoleScreenBufferInfo(hOutput, bInfo );
// 获取窗口缓冲区信息
//char strTitle[255];
//GetConsoleTitle(strTitle, 255); // 获取窗口标题
//printf("当前窗口标题是:%s\n", strTitle);
//_getch();
SetConsoleTitle(TEXT("推箱子")); // 获取窗口标题
//_getch();
COORD size = {80-20, 25+2};
SetConsoleScreenBufferSize(hOutput,size); // 重新设置缓冲区大小
//_getch();
SMALL_RECT rc = {0,0, 80-20, 25+2}; // 重置窗口位置和大小
SetConsoleWindowInfo(hOutput,true,&rc);
//CloseHandle(hOutput); // 关闭标准输出设备句柄
//创建新的缓冲区
hOutBuf = CreateConsoleScreenBuffer(
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
CONSOLE_TEXTMODE_BUFFER,
NULL
);
//设置新的缓冲区为活动显示缓冲
SetConsoleActiveScreenBuffer(hOutBuf);
//隐藏两个缓冲区的光标
CONSOLE_CURSOR_INFO cci;
cci.bVisible=0;
cci.dwSize=1;
SetConsoleCursorInfo(hOutput, &cci);
SetConsoleCursorInfo(hOutBuf, &cci);
//双缓冲处理显示
SetConsoleTextAttribute(hOutBuf,0|11);
TextManage();
while (1)
{
stopFlash();
DrawMapBase();
DrawMap();
ReadConsoleOutputCharacterA(hOutBuf, data, 720, coord, &bytes);
Sleep(30);
WriteConsoleOutputCharacterA(hOutput, data,720, coord, &bytes);
nextMap(); //函数调用顺序很重要,若放最后,会有推箱未完就换图之状
TextChange();
PlayGame();
}
return 0;
}
void DrawMapBase()
{
if(mapNumWait)//bool判断中勿再赋值
{
for(int m=0; m<14; m++)
{
for(int n=0; n<16; n++)
{
switch(mapNumGoing)
{
case 1:
map[m][n]=map1[m][n];
break;
case 2:
map[m][n]=map2[m][n];
break;
case 3:
map[m][n]=map3[m][n];
break;
case 4:
map[m][n]=map4[m][n];
break;
case 5:
map[m][n]=map5[m][n];
break;
case 6:
map[m][n]=map6[m][n];
break;
case 7:
map[m][n]=map7[m][n];
break;
case 8:
map[m][n]=map8[m][n];
break;
case 9:
map[m][n]=map9[m][n];
break;
case 10:
map[m][n]=map10[m][n];
break;
case 11:
map[m][n]=map11[m][n];
break;
case 12:
map[m][n]=map12[m][n];
break;
case 13:
map[m][n]=map13[m][n];
break;
case 14:
map[m][n]=map14[m][n];
break;
case 15:
map[m][n]=map15[m][n];
break;
case 16:
map[m][n]=map16[m][n];
break;
case 17:
map[m][n]=map17[m][n];
break;
case 18:
map[m][n]=map18[m][n];
break;
}
}
}
mapNumWait=false;
}
}
void DrawMap()
{
//用for循环遍历二维数组
for(int i=0; i<14; i++)
{
coord.X =2;
coord.Y =i+4;
SetConsoleCursorPosition( hOutBuf, coord );
for(int j=0; j<16; j++)
{
switch(map[i][j])
{
case 0:
//printf(" ");//空两格对应一个全角符
WriteConsole(hOutBuf, " ", strlen(" "), NULL, NULL);
break;
case 1:
//printf("■");
WriteConsole(hOutBuf, "■", strlen("■"), NULL, NULL);
break;
case 3:
//printf("◎");
WriteConsole(hOutBuf, "+", strlen("+"), NULL, NULL);
break;
case 4:
//printf("□");
WriteConsole(hOutBuf, "□", strlen("□"), NULL, NULL);
break;
case 5:
//printf("♀");
WriteConsole(hOutBuf, "♀", strlen("♀"), NULL, NULL);
break;
case 7:
//printf("¤");
WriteConsole(hOutBuf, "¤", strlen("¤"), NULL, NULL);
break; //若不用break则执行case8打印出"♀" 出错!
case 8:
//printf("♀");
WriteConsole(hOutBuf, "♀", strlen("♀"), NULL, NULL);
break;
}
}
//printf("\n");
WriteConsole(hOutBuf, "\n", strlen("\n"), NULL, NULL);
coord.X =2;
coord.Y =4;
}
}
void PlayGame()
{
char ch;
int pRow,pCol;//人的行和列
int i,j;
//时时刻刻得到人的下标,
for (i=0; i<14; i++)
{
for(j=0; j<16; j++)
{
if(map[i][j]==5||map[i][j]==8)
{
pRow=i;
pCol=j;
break;//此break只能跳出第一个for循环
}
}
if(map[i][j]==5||map[i][j]==8)//此句跳出第二个for循环 不可有goto语句
break;
}
ch=getch();//getchar()接收字符,显示回文件 在按下回车的时候结束。
//getch()接收字符 不显示回文件直接接收。
switch(ch)
{
case 'W':
case 'w':
case 72:
if(map[pRow-1][pCol]==0||map[pRow-1][pCol]==3)
{
map[pRow-1][pCol]+=5;
map[pRow][pCol]-=5;
}
else if(map[pRow-1][pCol]==4||map[pRow-1][pCol]==7)//人的前面是箱子
{
if(map[pRow-2][pCol]==0||map[pRow-2][pCol]==3)//判断箱子的前面为空或目标
{
map[pRow-2][pCol]+=4;
map[pRow-1][pCol]+=1;
map[pRow][pCol]-=5;
}
}
break;
case 'S':
case 's':
case 80:
if(map[pRow+1][pCol]==0||map[pRow+1][pCol]==3)
{
map[pRow+1][pCol]+=5;
map[pRow][pCol]-=5;
}
else if(map[pRow+1][pCol]==4||map[pRow+1][pCol]==7)
{
if(map[pRow+2][pCol]==0||map[pRow+2][pCol]==3)
{
map[pRow+2][pCol]+=4;
map[pRow+1][pCol]+=1;
map[pRow][pCol]-=5;
}
}
break;
case 'A':
case 'a':
case 75:
if(map[pRow][pCol-1]==0||map[pRow][pCol-1]==3)
{
map[pRow][pCol-1]+=5;
map[pRow][pCol]-=5;
}
else if(map[pRow][pCol-1]==4||map[pRow][pCol-1]==7)
{
if(map[pRow][pCol-2]==0||map[pRow][pCol-2]==3)
{
map[pRow][pCol-2]+=4;
map[pRow][pCol-1]+=1;
map[pRow][pCol]-=5;
}
}
break;
case 'D':
case 'd':
case 77:
if(map[pRow][pCol+1]==0||map[pRow][pCol+1]==3)
{
map[pRow][pCol+1]+=5;
map[pRow][pCol]-=5;
}
else if(map[pRow][pCol+1]==4||map[pRow][pCol+1]==7)
{
if(map[pRow][pCol+2]==0||map[pRow][pCol+2]==3)
{
map[pRow][pCol+2]+=4;
map[pRow][pCol+1]+=1;
map[pRow][pCol]-=5;
}
}
break;
case '=':
mapNumGoing=mapNumGoingC;
mapNumWait=true;
nextm=true;
iox=0;
break;
case 0xe://0xe是ctrl+N的键值
nextK=false;
jox=iox;
break;
default:
break;;
}
return;
}
void nextMap()
{
if(nextm)
{
for(int m=0; m<14; m++)
{
for(int n=0; n<16; n++)
{
if(map[m][n]==3||map[m][n]==7)
{
iox++;
}
}
}
nextm=false;
}
if(nextK)
{
jox=0;
for(int i=0; i<14; i++)
{
for(int j=0; j<16; j++)
{
if(map[i][j]==7)
{
jox++;
}
}
}
}
if(jox==iox)
{
if(mapNumGoing<18)
{
mapNumGoing++;
}
mapNumGoingC=mapNumGoing;
mapNumWait=true;
nextm=true;
nextK=true;
iox=0;
textc=true;
Sleep(2000);
DrawMapBase();
DrawMap();
ReadConsoleOutputCharacterA(hOutBuf, data, 720, coord, &bytes);
Sleep(30);
WriteConsoleOutputCharacterA(hOutput, data,720, coord, &bytes);
nextMap(); //函数调用顺序很重要,若放最后,会有推箱未完就换图之状
TextChange();
}
}
void TextManage()
{
WriteConsole(hOutBuf, "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n", stra, NULL, NULL);
WriteConsole(hOutBuf, "┃************************推箱子**************************┃\n", stra, NULL, NULL);
WriteConsole(hOutBuf, "┣━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┫\n", stra, NULL, NULL);
for(int h=0; h<15; h++)
{
WriteConsole(hOutBuf, "┃ ┃ ┃\n", stra, NULL, NULL);
}
WriteConsole(hOutBuf, "┣━━━━━━━━━━━━━━━━┻━━━━━━━━━━━┫\n", stra, NULL, NULL);
WriteConsole(hOutBuf, "┃推箱进程:推箱新手,开始吧!生命不息,推箱不止! ┃\n", stra, NULL, NULL);
WriteConsole(hOutBuf, "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n", stra, NULL, NULL);
WriteConsole(hOutBuf, "┃游戏操作:按下“=”键,重新开始当前关 ┃\n", stra, NULL, NULL);
WriteConsole(hOutBuf, "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n", stra, NULL, NULL);
WriteConsole(hOutBuf, "┃作 者:零千刻****************************************┃\n", stra, NULL, NULL);
WriteConsole(hOutBuf, "┃代码要点:关卡框架;控制台消除闪烁。********************┃\n", stra, NULL, NULL);
WriteConsole(hOutBuf, "┃关卡设计:参考易语言例程推箱子;代码:参考网络资源******┃\n", stra, NULL, NULL);
WriteConsole(hOutBuf, "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛", stra, NULL, NULL);
coord.X =36;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "关卡:第 一 关", strlen("关卡:第 一 关"), NULL, NULL);
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱新手", strlen( "称号:推箱新手"), NULL, NULL);
//新手,识途,有成,悟心,得道,仙人
coord.Y =8;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "操作:按键WSAD或wsad", strlen("操作:按键WSAD或wsad"), NULL, NULL);
coord.Y =9;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, " 或↑↓→←", strlen(" 或↑↓→←"), NULL, NULL);
coord.Y =11;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "说明:所有 □ 推至 十", strlen("说明:所有 □ 推至 十"), NULL, NULL);
coord.Y =12;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, " 共十八关,难度递增", strlen(" 共十八关,难度递增"), NULL, NULL);
coord.Y =13;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, " 目标达成,推箱仙人", strlen(" 目标达成,推箱仙人"), NULL, NULL);
coord.Y =15;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "激励:做得到,做得好!", strlen( "激励:做得到,做得好!"), NULL, NULL);
}
void stopFlash()
{
coord.X =52;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, " ", strlen(" "), NULL, NULL);//初行闪烁,用空代替。防闪
}
void TextChange()
{
if(textc)
{
switch(mapNumGoing)
{
case 2:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, " 二", strlen(" 二"), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱识途", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱识途,好的开始,向前向前! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 3:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, " 三", strlen(" 三"), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱识途", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱识途,略有进步,努力努力! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 4:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, " 四", strlen(" 四"), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱识途", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱识途,大有进步,向前向前! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 5:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, " 五", strlen(" 五"), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱识途", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱识途,即将升级,过关过关! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 6:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, " 六", strlen(" 六"), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱有成", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱有成,不忘初心,方得始终! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 7:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, " 七", strlen(" 六"), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱有成", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱有成,万里长城推不倒! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 8:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, " 八", strlen(" 六"), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱有成", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱有成,千里黄河水滔滔! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 9:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, " 九", strlen(" 六"), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱有成", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱有成,江山秀丽,叠彩峰岭! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 10:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, " 十", strlen(" 六"), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱悟心", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱悟心,天地任我行,实力在先! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 11:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "十一", strlen(" 六 "), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱悟心", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱悟心,推箱不语,正悟心得! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 12:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "十二", strlen(" 六 "), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱悟心", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱悟心,新的境界,感悟期待! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 13:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "十三", strlen(" 六 "), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱得道", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱得道,道可道,非常道,莫言! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 14:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "十四", strlen(" 六 "), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱得道", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱得道,一生二,二生三,三生万物! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 15:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "十五", strlen(" 六 "), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱得道", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱得道,若要升仙,先过此关! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 16:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "十六", strlen(" 六 "), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱仙人", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱仙人,有仙术,ctrl+ n 跳到下一关!! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 17:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "十七", strlen(" 六 "), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱仙人", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱仙人,飞升云天,胜利在望! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
case 18:
coord.X =44;
coord.Y =4;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "十八", strlen(" 六 "), NULL, NULL);
coord.X =36;
coord.Y =6;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf, "称号:推箱仙人", strlen( "称号:推箱识途"), NULL, NULL);
coord.X =12;
coord.Y =19;
SetConsoleCursorPosition( hOutBuf, coord );
WriteConsole(hOutBuf,"推箱仙人,天地变色,众生膜拜! ", strlen( "推箱识途,好的开始,向前向前! "), NULL, NULL);
break;
}
textc=false;
}
}
地图文件,只贴一关,做测试用:
//mapfile.cpp
int map1[14][16]=
{
{0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,1,1,1,1,1,0,0,0,0,0,0,0},//0空白
{0,0,1,0,0,0,1,0,0,0,0,0,0,0},//1墙
{0,0,1,0,4,0,1,0,1,1,1,0,0,0},//3目标
{0,0,1,0,4,5,1,0,1,3,1,0,0,0},//4箱子
{0,0,1,1,1,4,1,1,1,3,1,0,0,0},//5角色
{0,0,0,1,1,0,0,0,0,3,1,0,0,0},
{0,0,0,1,0,0,0,1,0,0,1,0,0,0},
{0,0,0,1,0,0,0,1,1,1,1,0,0,0},
{0,0,0,1,1,1,1,1,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0}
};
更多关卡参见完整项目资源,完整项目代码资源参见以下链接:
点击打开链接 http://download.csdn.net/detail/qq_38329891/9863990
有很奇怪的问题请教高人,
在CodeBlocks中编绎时,为什么release能通过,而debug却不能通过?
无意中发现的,找不到原因,好纠结!
程序有小bug,跳关后,有时程序会失灵,请高人指教!!