2024-3-20 【推箱子】

}

int WelcomePage(){

int i=0;

system(“cls”);

system(“color OE”);

printf(“\n\n\t\t Welcome to play box!\n\n”);

printf(“\t\t Person:♀ Wall:㊣ Box:■ Target:★ Reach target: ☆\n”);

printf(“\t\t Up:↑\n\t\t Down:↓\n\t\t Left: ←\n\t\t Right: →\n\n”);

printf(“\t\t Please number 1 to start new game\n\t\t\n”);

printf(“\t\t Please number 2 to choose level\n\t\t\n”);

printf(“\t\t Please number 3 to quit from game\n\t\t\n”);

printf(“\t\t Please right number to continue:”);

while (1){

i=getchar();

if(i>=49&&i<=51){

return i;

}

}

}

int PrintMap(int aiMap[][16],int iImp){

int i,j;

int iCount=0;

for(i=0;i<14;i++){

for(j=0;j<16;j++){

switch(aiMap[i][j]){

case 0:

printf(" ");

break;

case 1:

SelectColor(14);

printf(“㊣”);

break;

case 2:

printf(" ");

break;

case 3:

SelectColor(11);

printf(“★”);

break;

case 4:

SelectColor(11);

printf(“■”);

break;

case 5:

SelectColor(9);

printf(“☆”);

break;

case 6:

SelectColor(10);

printf(“♀”);

break;

}

}

printf(“\n”);

}

SelectColor(14);

printf(“\n”);

printf(“\tYou are in Level %d!\t\t\n”,iImp);

printf(“\tPress arrow keys to play the game!\t\n”);

printf(“\tPress N to the next level!\t\n”);

printf(“\tPress Q to return the home page!\t\n”);

return iCount;

}

void SelectColor(int iColor){

HANDLE hConsole =

GetStdHandle((STD_OUTPUT_HANDLE));

SetConsoleTextAttribute(hConsole,iColor);

}

void MoveBox(int aiMap[][16],int iPlayerX,int iPlayerY,int iSelect,int aiMap2[][16]){

int iplayerX1,iPlayerY1;

int iplayerX2,iPlayerY2;

switch(iSelect){

case 1:

iPlayerX1 = iPlayerX - 1;

iPlayerY1 = iPlayerY;

iPlayerX2 = iPlayerX - 2;

iPlayerY2 = iPlayerY;

break;

case 2:

iPlayerX1 = iPlayerX;

iPlayerY1 = iPlayerY - 1;

iPlayerX2 = iPlayerX;

iPlayerY2 = iPlayerY - 2;

break;

case 3:

iPlayerX1 = iPlayerX;

iPlayerY1 = iPlayerY + 1;

iPlayerX2 = iPlayerX;

iPlayerY2 = iPlayerY + 2;

break;

case 4:

iPlayerX1 = iPlayerX + 1;

iPlayerY1 = iPlayerY;

iPlayerX2 = iPlayerX + 2;

iPlayerY2 = iPlayerY;

break;

default:

break;

}

switch aiMap([iPlayerX1][iPlayerY1]){

case WALL:

break;

case SPACE:

case BOX:

case TARGET:

aiMap[iPlayerX1][iPlayerY1] = PERSON;

if(aiMap2[iPlayerX][iPlayerY]==TARGET||aiMap2[iPlayerX][iPlayerY]==TARGET_IN){

aiMap[iPlayerX][iPlayerY]=TARGET;

}else{

aiMap[iPlayerX][iPlayerY]=SPACE;

}

break;

case TARGET_IN:

if(aiMap[iPlayerX][iPlayerY]==TARGET){

aiMap[iPlayerX2][iPlayerY2]=TARGET_IN;

aiMap[iPlayerX1][iPlayerY1]=PERSON;

}else if(aiMap[iPlayerX2][iPlayerY2]==SPACE){

aiMap[iPlayerX2][iPlayerY2]=BOX;

aiMap[iPlayerX1][iPlayerY1]=PERSON;

}else{

break;

}

if(aiMap2[iPlayerX][iPlayerY]==TARGET||aiMap2[iPlayerX][iPlayerY]==TARGET_IN){

aiMap[iPlayerX][iPlayerY]==TARGET;

}else{

aiMap[iPlayerX][iPlayerY]==SPACE;

}

break;

}

}

void GetLevel1(){

int aiMap2[14][16];

int i,j,iSum=0;

int aiMap[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,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,1,0,0,0,0},

{0,0,0,0,1,1,1,2,2,2,2,1,0,0,0,0},

{0,0,0,1,1,3,4,2,1,1,2,1,1,0,0,0},

{0,0,0,1,2,3,4,6,4,2,2,3,1,0,0,0},

{0,0,0,1,2,3,2,4,2,4,3,1,1,0,0,0},

{0,0,0,1,1,1,1,1,1,2,2,1,0,0,0,0},

{0,0,0,0,0,0,0,0,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,0,0,0,0},

{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

};

for(i=0;i<14;i++){

for(j=0;j<16;j++){

aiMap2[i][j]=aiMap[i][j];

if(aiMap[i][j]==TARGET||aiMap[i][j]==TARGET_IN){

iSum++;

}

}

}

if(PlayGame(aiMap,aiMap2,iSum,2)!=KEY_RETURN){

GetLevel3();

}

}

void GetLevel2(){

int aiMap2[14][16];

int i,j,iSum=0;

int aiMap[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,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,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,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,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,0,0},

};

for(i=0;i<14;i++){

for(j=0;j<16;j++){

aiMap2[i][j]=aiMap[i][j];

if(aiMap[i][j]==TARGET||aiMap[i][j]==TARGET_IN){

iSum++;

}

}

}

if(PlayGame(aiMap,aiMap2,iSum,2)!=KEY_RETURN){

GetLevel3();

}

}

void GetLevel3(){

int aiMap2[14][16];

int i,j,iSum=0;

int aiMap[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,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,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,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,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,0,0},

};

for(i=0;i<14;i++){

for(j=0;j<16;j++){

aiMap2[i][j]=aiMap[i][j];

if(aiMap[i][j]==TARGET||aiMap[i][j]==TARGET_IN){

iSum++;

}

}

}

if(PlayGame(aiMap,aiMap2,iSum,3)!=KEY_RETURN){

GetLevel4();

}

}

void GetLevel4(){

int aiMap2[14][16];

int i,j,iSum=0;

int aiMap[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,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,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,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,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,0,0},

};

for(i=0;i<14;i++){

for(j=0;j<16;j++){

aiMap2[i][j]=aiMap[i][j];

if(aiMap[i][j]==TARGET||aiMap[i][j]==TARGET_IN){

iSum++;

}

}

}

PlayGame(aiMap,aiMap2,iSum,4);

}

int PlayGame(int aiMap[][16],int aiMap2[][16],int iSum,int iImp){

int i,j;

int iPlayerX,iPlayerY;

char cOp;

int iNum=0;

while(1){

for(i=0;i<14;i++){

for(j=0;j<16;j++){

if(aiMap[1][j]==PERSON){

break;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值