导航:首页 > 源码编译 > 怎么用推箱子编译

怎么用推箱子编译

发布时间:2022-04-12 06:10:37

Ⅰ 求一个用C语言编写的推箱子小游戏代码

若用VC环境下的C语言进行图像编程,理论上是不行的。不过好在已有高人解决了
压缩包内有文件源代码,与相应的插件,按说明安装即可
亲自测试
很抱歉,回答者上传的附件已失效

Ⅱ 怎么用C语言编写推箱子的简单小游戏

http://blog.csdn.net/pastthewind/article/details/52456178,这里面有代码

Ⅲ 用vc++编写推箱子程序的具体步骤

你可以到魔方吧推箱子论坛问问,那里有很多编程高手
http://bbs.mf8-china.com/forum.php?mod=forumdisplay&fid=57

Ⅳ 紧急求救:用C语言编写推箱子游戏的程序!!

给:
#include"stdio.h"
#include"bios.h"
#define LEFT 75
#define RIGHT 77
#define UPPER 72
#define DOWN 80
#define ESC 27
struct Boxss /*定义箱子结构体,其中包含坐标属性*/
{
int x,y;
};
union keyboard /*定义读取键盘码的共用体类型*/
{
unsigned int iKeyInfo;
char chKeyBit[2];
};
int fnGetKey(void) /*定义读取键盘码的函数*/
{
union keyboard uniKey1; /*定义读取键盘码的共用体变量*/
while(bioskey(1)==0); /*检测用户是否按键*/
uniKey1.iKeyInfo=bioskey(0); /*读取按键信息*/
return(uniKey1.chKeyBit[0]==0?uniKey1.chKeyBit[1]:uniKey1.chKeyBit[0]); /*返回ASCII码或扩充码*/
}
void main()
{
int iKey,x=11,y=6,tx=11,ty=6; /*x,y为人物移动后坐标,tx,ty为人物移动前坐标*/
struct Boxss Box[4]; /*定义箱子数量*/
int chMap[10][10]={ /*用二维数组定义地图*/
{0,0,0,0,0,0,0,0,0,0}, /*0表示墙1表示路2表示目标*/
{0,1,0,0,0,0,1,1,1,0},
{0,1,0,2,0,0,1,0,1,0},
{0,1,0,1,0,0,1,0,1,0},
{0,1,1,1,0,0,1,0,1,0},
{0,1,0,0,0,0,1,0,1,0},
{0,1,1,1,1,1,1,0,1,0},
{0,1,0,1,0,0,0,0,2,0},
{0,2,0,1,1,1,1,2,0,0},
{0,0,0,0,0,0,0,0,0,0},
};
int i,j;
Box[0].x=13; /*定义箱子的坐标属性*/
Box[1].x=11;
Box[2].x=14;
Box[3].x=18;
Box[0].y=8;
Box[1].y=7;
Box[2].y=13;
Box[3].y=7;
while(1) /*反复进行求移动的坐标运算*/
{
for(i=0;i<10;i++) /*输出新地图(刷新地图)*/
{
gotoxy(10,5+i);
for(j=0;j<10;j++)
{
if(chMap[i][j]==0)
printf("#");
if(chMap[i][j]==1)
printf(" ");
if(chMap[i][j]==2)
printf("X");
}
}
j=0; /*判断是否所有箱子都在目标坐标上*/
for(i=0;i<4;i++)
if(chMap[Box[i].y-5][Box[i].x-10]==2)
j++;
if(j==4) /*如果所有箱子都就位输出"YOU WIN!"退出*/
{
clrscr();
printf("You Win!");
break;
}
for(i=0;i<4;i++) /*在起始(或移动后)的坐标输出箱子*/
{
gotoxy(Box[i].x,Box[i].y);
printf("0");
}
gotoxy(x,y); /*在起始(或移动后)的坐标输出人*/
printf("*\b");
tx=x; /*记录本次移动前的坐标*/
ty=y;
iKey=fnGetKey();
if(iKey==LEFT&&chMap[y-5][x-1-10]!=0) /*按读取的按键信息改变坐标如果改变的坐标和墙(0)重合则不改变*/
x--;
if(iKey==RIGHT&&chMap[y-5][x+1-10]!=0)
x++;
if(iKey==UPPER&&chMap[y-1-5][x-10]!=0)
y--;
if(iKey==DOWN&&chMap[y+1-5][x-10]!=0)
y++; /*输入ESC退出并输出"YOU LOST"*/
if(iKey==ESC)
{
clrscr();
printf("You Lost");
break;
}
for(i=0;i<4;i++) /*如果移动后的人的坐标与箱子坐标重合,则改变箱子坐标向前一格*/
if(Box[i].x==x&&Box[i].y==y)
{
Box[i].x+=(x-tx);
Box[i].y+=(y-ty);
if(chMap[Box[i].y-5][Box[i].x-10]==0) /*如果移动后的箱子坐标会出现在墙上,则使箱子坐标和人坐标都返回移动前的值*/
{
Box[i].x-=(x-tx);
Box[i].y-=(y-ty);
x=tx;
y=ty;
}
break;
}
clrscr();
}
getch();
}

Ⅳ 有没有人知道怎么用C语言编写一个推箱子的小游戏啊我不想要网上那些找的

C语言? 查查

Ⅵ 如何用C语言编写一如图模型的推箱子游戏的程序!

/*TC环境下编的*/
#include <dos.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <bios.h>
#include <alloc.h>

typedef struct winer
{
int x,y;
struct winer *p;
}winer;

char status [20][20];
char far *printScreen=(char far* )0xB8000000;

void putoutChar(int y,int x,char ch,char fc,char bc);
void printWall(int x, int y);
void printBox(int x, int y);
void printBoxDes(int x, int y);
void printDestination(int x, int y);
void printDestination1(int x,int y,winer **win,winer **pw);
void printMan(int x, int y);
void init();
winer *initStep1();
winer *initStep2();
winer *initStep3();
winer *initStep4();
void moveBoxSpacetoSpace(int x ,int y, char a);
void moveBoxDestoSpace(int x ,int y, char a) ;
void moveBoxSpacetoDes(int x, int y, char a);
void moveBoxDestoDes(int x, int y, char a);
int judge(int x, int y);
void move(int x, int y, char a);
void reset(int i);

void putoutChar(int y,int x,char ch,char fc,char bc)
{
printScreen[(x*160)+(y<<1)+0]=ch;
printScreen[(x*160)+(y<<1)+1]=(bc*16)+fc;
}
void printWall(int x,int y)
{
putoutChar(y-1,x-1,219,GREEN,BLACK);
status[x][y]='w';
}

void printBox(int x,int y)
{
putoutChar(y-1,x-1,10,WHITE,BLACK);
status[x][y]='b';
}

void printDestination1(int x,int y,winer **win,winer **pw)
{
winer *qw;
putoutChar(y-1,x-1,003,YELLOW,BLACK);
status[x][y]='m';
if(*win==NULL)
{
*win=*pw=qw=(winer* )malloc(sizeof(winer));
(*pw)->x=x;
(*pw)->y=y;
(*pw)->p=NULL;
}
else
{
qw=(winer* )malloc(sizeof(winer));
qw->x=x;
qw->y=y;
(*pw)->p=qw;
(*pw)=qw;qw->p=NULL;
}
}

void printDestination(int x,int y)
{
putoutChar(y-1,x-1,003,YELLOW,BLACK);
status[x][y]='m';
}

void printMan(int x,int y)
{
gotoxy(y,x);
_AL=02;
_CX=01;
_AH=0xa;
geninterrupt(0x10);
}

void printBoxDes(int x,int y)
{
putoutChar(y-1,x-1,10,YELLOW,BLACK);
status[x][y]='i';
}

void init()
{
int i,j;
for(i=0;i<20;i++)
for(j=0;j<20;j++)
status[i][j]=0;
_AL=3;
_AH=0;
geninterrupt(0x10);
gotoxy(40,4);
printf("Welcome to the box world!");
gotoxy(40,6);
printf("You can use up, down, left,");
gotoxy(40,8);
printf("right key to control it, or");
gotoxy(40,10);
printf("you can press Esc to quit it.");
gotoxy(40,12);
printf("Press space to reset the game.");
gotoxy(40,14);
printf("Wish you have a good time !");
gotoxy(40,16);
printf("April , 2007");

}
winer *initStep1()
{
int x;
int y;
winer *win=NULL;
winer *pw;
for(x=1,y=5;y<=9;y++)
printWall(x+4,y+10);
for(y=5,x=2;x<=5;x++)
printWall(x+4,y+10);
for(y=9,x=2;x<=5;x++)
printWall(x+4,y+10);
for(y=1,x=3;x<=8;x++)
printWall(x+4,y+10);
for(x=3,y=3;x<=5;x++)
printWall(x+4,y+10);
for(x=5,y=8;x<=9;x++)
printWall(x+4,y+10);
for(x=7,y=4;x<=9;x++)
printWall(x+4,y+10);
for(x=9,y=5;y<=7;y++)
printWall(x+4,y+10);
for(x=8,y=2;y<=3;y++)
printWall(x+4,y+10);
printWall(5+4,4+10);
printWall(5+4,7+10);
printWall(3+4,2+10);
printBox(3+4,6+10);
printBox(3+4,7+10);
printBox(4+4,7+10);
printDestination1(4+4,2+10,&win,&pw);
printDestination1(5+4,2+10,&win,&pw);
printDestination1(6+4,2+10,&win,&pw);
printMan(2+4,8+10);
return win;
}

winer *initStep2()
{
int x;
int y;
winer *win=NULL;
winer *pw;
for(x=1,y=4;y<=7;y++)
printWall(x+4,y+10);
for(x=2,y=2;y<=4;y++)
printWall(x+4,y+10);
for(x=2,y=7;x<=4;x++)
printWall(x+4,y+10);
for(x=4,y=1;x<=8;x++)
printWall(x+4,y+10);
for(x=8,y=2;y<=8;y++)
printWall(x+4,y+10);
for(x=4,y=8;x<=8;x++)
printWall(x+4,y+10);
for(x=4,y=6;x<=5;x++)
printWall(x+4,y+10);
for(x=3,y=2;x<=4;x++)
printWall(x+4,y+10);
for(x=4,y=4;x<=5;x++)
printWall(x+4,y+10);
printWall(6+4,3+10);
printBox(3+4,5+10);
printBox(6+4,6+10);
printBox(7+4,3+10);
printDestination1(5+4,7+10,&win,&pw);
printDestination1(6+4,7+10,&win,&pw);
printDestination1(7+4,7+10,&win,&pw);
printMan(2+4,6+10);
return win;
}
winer *initStep3()
{
int x;
int y;
winer *win=NULL;
winer *pw;
for(x=1,y=2;y<=8;y++)
printWall(x+4,y+10);
for(x=2,y=2;x<=4;x++)
printWall(x+4,y+10);
for(x=4,y=1;y<=3;y++)
printWall(x+4,y+10);
for(x=5,y=1;x<=8;x++)
printWall(x+4,y+10);
for(x=8,y=2;y<=5;y++)
printWall(x+4,y+10);
for(x=5,y=5;x<=7;x++)
printWall(x+4,y+10);
for(x=7,y=6;y<=9;y++)
printWall(x+4,y+10);
for(x=3,y=9;x<=6;x++)
printWall(x+4,y+10);
for(x=3,y=6;y<=8;y++)
printWall(x+4,y+10);
printWall(2+4,8+10);
printWall(5+4,7+10);
printBox(6+4,3+10);
printBox(4+4,4+10);
printBox(5+4,6+10);
printDestination1(2+4,5+10,&win,&pw);
printDestination1(2+4,6+10,&win,&pw);
printDestination1(2+4,7+10,&win,&pw);
printMan(2+4,4+10);
return win;
}

winer *initStep4()
{
int x;
int y;
winer *win=NULL;
winer *pw;
for(x=1,y=1;y<=6;y++)
printWall(x+4,y+10);
for(x=2,y=7;y<=8;y++)
printWall(x+4,y+10);
for(x=2,y=1;x<=7;x++)
printWall(x+4,y+10);
for(x=7,y=2;y<=4;y++)
printWall(x+4,y+10);
for(x=6,y=4;y<=9;y++)
printWall(x+4,y+10);
for(x=3,y=9;x<=5;x++)
printWall(x+4,y+10);
for(x=3,y=3;y<=4;y++)
printWall(x+4,y+10);
printWall(3+4,8+10);
printBox(3+4,5+10);
printBox(4+4,4+10);
printBox(4+4,6+10);
printBox(5+4,5+10);
printBox(5+4,3+10);
printDestination1(3+4,7+10,&win,&pw);
printDestination1(4+4,7+10,&win,&pw);
printDestination1(5+4,7+10,&win,&pw);
printDestination1(4+4,8+10,&win,&pw);
printDestination1(5+4,8+10,&win,&pw);
printMan(2+4,2+10);
return win;
}

void moveBoxSpacetoSpace(int x,int y,char a)
{
switch(a)
{
case 'u':
status[x-1][y]=0;
printf(" ");
printBox(x-2,y);
printMan(x-1,y);
status[x-2][y]='b';
break;
case 'd':
status[x+1][y]=0;
printf(" ");
printBox(x+2,y);
printMan(x+1,y);
status[x+2][y]='b';
break;
case 'l':
status[x][y-1]=0;
printf(" ");
printBox(x,y-2);
printMan(x,y-1);
status[x][y-2]='b';
break;
case 'r':
status[x][y+1]=0;
printf(" ");
printBox(x,y+2);
printMan(x,y+1);
status[x][y+2]='b';
break;
default:
break;
}
}

void moveBoxDestoSpace(int x,int y,char a)
{
switch(a)
{
case 'u':
status[x-1][y]='m';
printf(" ");
printBox(x-2,y);
printMan(x-1,y);
status[x-2][y]='b';
break;
case 'd':
status[x+1][y]='m';
printf(" ");
printBox(x+2,y);
printMan(x+1,y);
status[x+2][y]='b';
break;
case 'l':
status[x][y-1]='m';
printf(" ");
printBox(x,y-2);
printMan(x,y-1);
status[x][y-2]='b';
break;
case 'r':
status[x][y+1]='m';
printf(" ");
printBox(x,y+2);
printMan(x,y+1);
status[x][y+2]='b';
break;
default:
break;
}
}

void moveBoxSpacetoDes(int x,int y,char a)
{
switch(a)
{
case 'u':
status[x-1][y]=0;
printf(" ");
printBoxDes(x-2,y);
printMan(x-1,y);
status[x-2][y]='i';
break;
case 'd':
status[x+1][y]=0;
printf(" ");
printBoxDes(x+2,y);
printMan(x+1,y);
status[x+2][y]='i';
break;
case 'l':
status[x][y-1]=0;
printf(" ");
printBoxDes(x,y-2);
printMan(x,y-1);
status[x][y-2]='i';
break;
case 'r':
status[x][y+1]=0;
printf(" ");
printBoxDes(x,y+2);
printMan(x,y+1);
status[x][y+2]='i';
break;
default:
break;
}
}

void moveBoxDestoDes(int x,int y,char a)
{
switch(a)
{
case 'u':
status[x-1][y]='m';
printf(" ");
printBoxDes(x-2,y);
printMan(x-1,y);
status[x-2][y]='i';
break;
case 'd':
status[x+1][y]='m';
printf(" ");
printBoxDes(x+2,y);
printMan(x+1,y);
status[x+2][y]='i';
break;
case 'l':
status[x][y-1]='m';
printf(" ");
printBoxDes(x,y-2);
printMan(x,y-1);
status[x][y-2]='i';
break;
case 'r':
status[x][y+1]='m';
printf(" ");
printBoxDes(x,y+2);
printMan(x,y+1);
status[x][y+2]='i';
break;
default:
break;
}
}

int judge(int x,int y)
{
int i;
switch(status[x][y])
{
case 0:
i=1;
break;
case 'w':
i=0;
break;
case 'b':
i=2;
break;
case 'i':
i=4;
break;
case 'm':
i=3;
break;
default:
break;
}
return i;
}

void move(int x,int y,char a)
{
switch(a)
{
case 'u':
if(!judge(x-1,y))
{
gotoxy(y,x);
break;
}
else if(judge(x-1,y)==1||judge(x-1,y)==3)
{
if(judge(x,y)==3)
{
printDestination(x,y);
printMan(x-1,y);
break;
}
else
{
printf(" ");
printMan(x-1,y);
break;
}
}
else if(judge(x-1,y)==2)
{
if(judge(x-2,y)==1)
{
moveBoxSpacetoSpace(x,y,'u');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y,x-1);
}
else if(judge(x-2,y)==3)
{
moveBoxSpacetoDes(x,y,'u');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y,x-1);
}
else
gotoxy(y,x);
break;
}
else if(judge(x-1,y)==4)
{
if(judge(x-2,y)==1)
{
moveBoxDestoSpace(x,y,'u');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y,x-1);
}
else if(judge(x-2,y)==3)
{
moveBoxDestoDes(x,y,'u');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y,x-1);
}
else
gotoxy(y,x);
break;
}
case 'd':
if(!judge(x+1,y))
{
gotoxy(y,x);
break;
}
else if(judge(x+1,y)==1||judge(x+1,y)==3)
{
if(judge(x,y)==3)
{
printDestination(x,y);
printMan(x+1,y);
break;
}
else
{
printf(" ");
printMan(x+1,y);
break;
}
}
else if(judge(x+1,y)==2)
{
if(judge(x+2,y)==1)
{
moveBoxSpacetoSpace(x,y,'d');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y,x+1);
}
else if(judge(x+2,y)==3)
{
moveBoxSpacetoDes(x,y,'d');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y,x+1);
}
else
gotoxy(y,x);
break;
}
else if(judge(x+1,y)==4)
{
if(judge(x+2,y)==1)
{
moveBoxDestoSpace(x,y,'d');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y,x+1);
}
else if(judge(x+2,y)==3)
{
moveBoxDestoDes(x,y,'d');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y,x+1);
}
else
gotoxy(y,x);
break;
}
case 'l':
if(!judge(x,y-1))
{
gotoxy(y,x);
break;
}
else if(judge(x,y-1)==1||judge(x,y-1)==3)
{
if(judge(x,y)==3)
{
printDestination(x,y);
printMan(x,y-1);
break;
}
else
{
printf(" ");
printMan(x,y-1);
break;
}
}
else if(judge(x,y-1)==2)
{
if(judge(x,y-2)==1)
{
moveBoxSpacetoSpace(x,y,'l');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y-1,x);
}
else if(judge(x,y-2)==3)
{
moveBoxSpacetoDes(x,y,'l');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y-1,x);
}
else
gotoxy(y,x);
break;
}
else if(judge(x,y-1)==4)
{
if(judge(x,y-2)==1)
{
moveBoxDestoSpace(x,y,'l');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y-1,x);
}
else if(judge(x,y-2)==3)
{
moveBoxDestoDes(x,y,'l');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y-1,x);
}
else
gotoxy(y,x);
break;
}
case 'r':
if(!judge(x,y+1))
{
gotoxy(y,x);
break;
}
else if(judge(x,y+1)==1||judge(x,y+1)==3)
{
if(judge(x,y)==3)
{
printDestination(x,y);
printMan(x,y+1);
break;
}
else
{
printf(" ");
printMan(x,y+1);
break;
}
}
else if(judge(x,y+1)==2)
{
if(judge(x,y+2)==1)
{
moveBoxSpacetoSpace(x,y,'r');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y+1,x);
}
else if(judge(x,y+2)==3)
{
moveBoxSpacetoDes(x,y,'r');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y+1,x);
}
else
gotoxy(y,x);
break;
}
else if(judge(x,y+1)==4)
{
if(judge(x,y+2)==1)
{
moveBoxDestoSpace(x,y,'r');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y+1,x);
}
else if(judge(x,y+2)==3)
{
moveBoxDestoDes(x,y,'r');
if(judge(x,y)==3)
printDestination(x,y);
gotoxy(y+1,x);
}
else
gotoxy(y,x);
break;
}
default:
break;
}
}

void reset(int i)
{
switch(i)
{
case 0:
init();
initStep1();
break;
case 1:
init();
initStep2();
break;
case 2:
init();
initStep3();
break;
case 3:
init();
initStep4();
break;
default:
break;
}
}

void main()
{
int key;
int x;
int y;
int s;
int i=0;
winer *win;
winer *pw;
_AL=3;
_AH=0;
geninterrupt(0x10);
init();
win=initStep1();
do{
_AH=3;
geninterrupt(0x10);
x=_DH+1;
y=_DL+1;
while(bioskey(1)==0);
key=bioskey(0);
switch(key)
{
case 0x4800:
move(x,y,'u');
break;
case 0x5000:
move(x,y,'d');
break;
case 0x4b00:
move(x,y,'l');
break;
case 0x4d00:
move(x,y,'r');
break;
case 0x3920:
reset(i);
break;
default:
break;
}
s=0;
pw=win;
while(pw)
{
if(status[pw->x][pw->y]=='m')
s++;
pw=pw->p;
}
if(s==0)
{
free(win);
gotoxy(25,2);
printf("congratulate! You have done this step!");
getch();
i++;
switch(i)
{
case 1:
init();
win=initStep2();
break;
case 2:
init();
win=initStep3();
break;
case 3:
init();
win=initStep4();
break;
case 4:
gotoxy(15,21);
printf("Congratulation! \n");
gotoxy(15,23);
printf("You have done all the steps, Welcome to play again!");
key=0x011b;
getch();
break;
default:
break;
}
}

}while(key!=0x011b);
_AL=3;
_AH=0;
geninterrupt(0x10);
}

Ⅶ 用C语言如何编写推箱子,给个思路呗

#include<stdio.h>

#include <conio.h>

#include <windows.h>

#define R 2//小人

#define B 4//箱子

#define O 3//目的地

#define W 43//墙

#define RO 5//箱子与人重合

#define BO 6//箱子与目的地重合

#define Size 13//数组大小

int main ()

{

printf ("推箱子(1~10关): wasd或↑↓←→控制方向。n下一关。r重新开始。 请注意输入法是否为小写英文输入 ");

system ("pause");

MessageBox (NULL,"第一关"," ",MB_OK);//第一关

int move (char a[Size][Size]);

char a[Size][Size]={0};

int i,j;

void all0 (char a[Size][Size]);

NO1:

all0 (a);

for (i=3;i<6;i++)

a[0][i]=W;

a[1][3]=W;

a[1][5]=W;

for (i=0;i<4;i++)

a[2][i]=W;

a[2][5]=W;

a[3][0]=W;

for (i=0;i<3;i++)

a[4][i]=W;

a[4][7]=W;

for (i=5;i<8;i++)

{

a[3][i]=W;

a[i][2]=W;

a[i][4]=W;

a[5][i]=W;

}

a[7][3]=W;

a[1][4]=O;

a[3][1]=O;

a[4][6]=O;

a[6][3]=O;

a[3][2]=B;

a[3][4]=B;

a[4][4]=B;

a[5][3]=B;

a[4][3]=R;

if (move (a))

{

printf ("WIN ");

system ("pause");

}

else

goto NO1;

MessageBox (NULL,"第二关"," ",MB_OK);//第二关

NO2:

all0 (a);

for (i=0;i<5;i++)

{

a[i][0]=W;

a[0][i]=W;

a[i][4]=W;

}

a[5][2]=W;

a[4][2]=W;

for (i=4;i<9;i++)

a[i][1]=W;

for (i=2;i<6;i++)

a[8][i]=W;

a[6][5]=W;

for (i=5;i<9;i++)

a[7][i]=W;

for (i=2;i<8;i++)

a[i][8]=W;

a[2][7]=W;

for (i=2;i<5;i++)

a[i][6]=W;

a[4][5]=W;

a[1][1]=R;

a[2][2]=B;

a[2][3]=B;

a[3][2]=B;

a[3][7]=O;

a[4][7]=O;

a[5][7]=O;

if (move (a))

{

printf ("WIN ");

system ("pause");

}

else

goto NO2;

MessageBox (NULL,"第三关"," ",MB_OK);//第三关

NO3:

all0 (a);

for (i=1;i<8;i++)

a[0][i]=W;

a[1][1]=W;

for (i=7;i<10;i++)

a[1][i]=W;

for (i=0;i<2;i++)

a[2][i]=W;

for (i=3;i<6;i++)

a[2][i]=W;

a[2][9]=W;

a[3][0]=W;

a[3][9]=W;

a[4][0]=W;

a[4][4]=W;

a[4][9]=W;

a[4][8]=W;

a[5][0]=W;

a[5][1]=W;

a[5][4]=W;

a[5][8]=W;

for (i=1;i<9;i++)

a[6][i]=W;

a[2][2]=B;

a[3][4]=B;

a[3][2]=R;

a[3][7]=B;

a[4][6]=B;

a[4][2]=O;

a[4][3]=O;

a[5][2]=O;

a[5][3]=O;

if (move (a))

{

printf ("WIN ");

system ("pause");

}

else

goto NO3;

MessageBox (NULL,"第四关"," ",MB_OK);//第四关

NO4:

all0 (a);

for (i=1;i<5;i++)

{a[0][i]=W;a[7][i]=W;}

a[1][1]=W;

a[1][4]=W;

a[2][1]=R;

a[2][2]=B;

a[2][4]=W;

a[3][1]=W;

a[3][2]=B;

a[3][4]=W;

a[3][5]=W;

a[4][1]=W;

for (i=1;i<8;i++)

a[i][0]=W;

a[4][3]=B;

a[5][2]=B;

a[5][1]=O;

a[6][1]=O;

a[6][2]=O;

a[6][3]=BO;

a[6][4]=O;

for (i=1;i<4;i++)

a[i][4]=W;

for (i=3;i<8;i++)

a[i][5]=W;

if (move (a))

{

printf ("WIN ");

system ("pause");

}

else

goto NO4;

MessageBox (NULL,"第五关"," ",MB_OK);//第五关

NO5:

all0 (a);

for (i=1;i<6;i++)

a[0][i]=W;

for (i=1;i<4;i++)

a[i][1]=W;

for (i=3;i<8;i++)

a[i][0]=W;

for (i=1;i<8;i++)

a[7][i]=W;

for (i=4;i<7;i++)

{a[1][i]=W;a[i][1]=O;}

for (i=3;i<7;i++)

a[i][7]=W;

a[2][6]=W;

a[3][6]=W;

a[1][2]=R;

a[2][3]=B;

a[3][2]=W;

a[4][2]=W;

a[3][4]=W;

a[4][4]=W;

a[5][5]=W;

a[5][2]=B;

a[6][5]=B;

if (move (a))

{

printf ("WIN ");

system ("pause");

}

else

goto NO5;

MessageBox (NULL,"第六关"," ",MB_OK);//第六关

NO6:

all0 (a);

for (i=1;i<8;i++)

a[i][0]=W;

for (i=7;i<11;i++)

a[i][1]=W;

for (i=1;i<4;i++)

{a[1][i]=W;a[i][9]=W;}

for (i=3;i<10;i++)

a[0][i]=W;

for (i=3;i<8;i++)

a[i][10]=W;

for (i=7;i<11;i++)

a[i][12]=W;

a[7][11]=W;

for (i=2;i<13;i++)

a[10][i]=W;

for (i=3;i<6;i++)

{a[i][2]=W;a[8][i]=W;}

for (i=5;i<8;i++)

{a[2][i]=W;a[i][8]=W;}

a[3][4]=W;

a[6][3]=W;

a[4][7]=W;

a[7][6]=W;

a[9][8]=W;

a[9][7]=W;

a[2][4]=O;

a[6][2]=O;

a[4][8]=O;

a[8][6]=O;

a[4][4]=B;

a[4][6]=B;

a[5][5]=BO;

a[6][4]=B;

a[6][6]=B;

a[8][11]=R;

if (move (a))

{

printf ("WIN ");

system ("pause");

}

else

goto NO6;

MessageBox (NULL,"第七关"," ",MB_OK);//第七关

NO7:

all0 (a);

for (i=3;i<10;i++)

a[0][i]=W;

for (i=1;i<6;i++)

a[i][2]=W;

for (i=5;i<8;i++)

a[i][0]=W;

a[5][1]=W;

a[1][3]=W;

a[6][0]=W;

for (i=0;i<9;i++)

a[7][i]=W;

a[5][8]=W;

a[6][8]=W;

for (i=1;i<6;i++)

a[i][9]=W;

a[1][6]=W;

a[2][6]=W;

a[4][5]=W;

a[4][6]=W;

a[5][6]=W;

a[3][3]=B;

a[3][5]=B;

a[3][7]=B;

a[4][4]=B;

a[5][4]=B;

a[1][8]=R;

for (i=1;i<6;i++)

a[6][i]=O;

if (move (a))

{

printf ("WIN ");

system ("pause");

}

else

goto NO7;

MessageBox (NULL,"第八关"," ",MB_OK);//第八关

NO8:

all0 (a);

for (i=3;i<9;i++)

a[0][i]=W;

for (i=1;i<4;i++)

a[1][i]=W;

a[2][1]=W;

a[1][8]=W;

a[2][8]=W;

for (i=2;i<6;i++)

a[i][0]=W;

for (i=1;i<6;i++)

a[5][i]=W;

for (i=2;i<5;i++)

a[i][9]=W;

for (i=4;i<7;i++)

a[i][8]=W;

for (i=5;i<9;i++)

a[6][i]=W;

a[2][5]=W;

a[2][6]=W;

a[2][4]=B;

a[3][3]=B;

a[3][5]=B;

a[4][4]=B;

a[4][6]=B;

a[3][8]=R;

a[3][1]=O;

a[4][1]=O;

for (i=2;i<5;i++)

a[i][2]=O;

if (move (a))

{

printf ("WIN ");

system ("pause");

}

else

goto NO8;

MessageBox (NULL,"第九关"," ",MB_OK);//第九关

NO9:

all0 (a);

for (i=1;i<10;i++)

{a[0][i]=W;a[8][i]=W;}

for (i=1;i<6;i++)

{a[i][1]=W;a[i][9]=W;}

for (i=5;i<9;i++)

{a[i][0]=W;a[i][10]=W;}

for (i=4;i<7;i++)

{a[3][i]=W;a[4][i]=O;a[5][i]=O;}

a[1][4]=W;

a[1][5]=W;

a[4][3]=W;

a[5][3]=W;

a[4][7]=W;

a[5][7]=W;

a[7][6]=W;

a[2][5]=B;

a[3][2]=B;

a[3][8]=B;

a[6][2]=B;

a[6][5]=B;

a[6][8]=B;

a[7][8]=R;

if (move (a))

{

printf ("WIN ");

system ("pause");

}

else

goto NO9;

MessageBox (NULL,"第十关"," ",MB_OK);//第十关

NO10:

all0 (a);

for (i=2;i<8;i++)

a[0][i]=W;

a[1][2]=W;

for (i=0;i<2;i++)

a[2][i]=W;

for (i=3;i<6;i++)

a[i][0]=W;

for (i=1;i<4;i++)

a[5][i]=W;

for (i=3;i<7;i++)

a[6][i]=W;

for (i=1;i<5;i++)

a[i][7]=W;

a[4][6]=W;

a[5][6]=W;

a[3][1]=R;

for (i=3;i<6;i++)

{a[2][i]=B;a[4][i]=O;}

a[3][3]=B;

a[3][4]=O;

a[3][5]=O;

a[4][2]=B;

if (move (a))

{

printf ("WIN ");

system ("pause");

}

else

goto NO10;

MessageBox(NULL,"恭喜您通关了。"," ",MB_OK);

return 0;

}

int move (char a[Size][Size])//控制小人的移动

{

int condition (char a [Size][Size],int x,int y,int b,int c,int d,int e);

void print ( char a [Size][Size]);

int x,y;

char c;

int i,j;

for (i=0;i<Size;i++)//给小人定位

for (j=0;j<Size;j++)

if (a[i][j]==R)

{ x=i;y=j; }

print (a);

loop:

c=getch();

if (c==0)//如果是键盘上下左右键用扫描码

c=getch();

switch(c)

{

case 'n':

case 'N': return 1;//下一关

case 'r':

case 'R': return 0;//返回0,重新开始

case 'w':

case 'W':

case 72: if (condition(a,x,y,x-1,y,x-2,y))x=x-1;break;//上

case 'a':

case 'A':

case 75: if (condition(a,x,y,x,y-1,x,y-2))y=y-1;break;//下

case 's':

case 'S':

case 80: if (condition(a,x,y,x+1,y,x+2,y))x=x+1;break;//左

case 'd':

case 'D':

case 77: if (condition(a,x,y,x,y+1,x,y+2))y=y+1;break;//右

default : goto loop;

}

print (a);

for (i=0;i<Size;i++)//用是否存在箱子作胜利条件

for (j=0;j<Size;j++)

if (a[i][j]==B)

goto loop;

return 1;

}

void print ( char a [Size][Size])//输出数组函数

{

int i,j;

system ("cls");//清屏函数

for (i=0;i<Size;i++)

{

for (j=0;j<Size;j++)

if (a[i][j]!=0)

printf ("%2c",a[i][j]);

else

printf (" ");

printf (" ");

}

printf (" ");

}

int condition (char a [Size][Size],int x,int y,int b,int c,int d,int e)//小人移动后的情况处理

{

if (a[b][c]!=W)

{

if (a[x][y]==R&&a[b][c]==0)

{a[x][y]=0;a[b][c]=R;return 1;}

if (a[x][y]==RO&&a[b][c]==0)

{a[x][y]=O;a[b][c]=R;return 1;}

if ((a[x][y]==R||a[x][y]==RO)&&(a[b][c]==B||a[b][c]==BO)&&(a[d][e]==B||a[d][e]==BO||a[d][e]==W))

return 0;

if (a[x][y]==R&&a[b][c]==O)

{a[x][y]=0;a[b][c]=RO;return 1;}

if (a[x][y]==RO&&a[b][c]==O)

{a[x][y]=O;a[b][c]=RO;return 1;}

if (a[x][y]==R&&a[b][c]==B&&a[d][e]==O)

{a[x][y]=0;a[b][c]=R;a[d][e]=BO;return 1;}

if (a[x][y]==R&&a[b][c]==B&&a[d][e]==0)

{a[x][y]=0;a[b][c]=R;a[d][e]=B;return 1;}

if (a[x][y]==R&&a[b][c]==BO&&a[d][e]==0)

{a[x][y]=0;a[b][c]=RO;a[d][e]=B;return 1;}

if (a[x][y]==R&&a[b][c]==BO&&a[d][e]==O)

{a[x][y]=0;a[b][c]=RO;a[d][e]=BO;return 1;}

if (a[x][y]==RO&&a[b][c]==B&&a[d][e]==O)

{a[x][y]=O;a[b][c]=R;a[d][e]=BO;return 1;}

if (a[x][y]==RO&&a[b][c]==B&&a[d][e]==0)

{a[x][y]=O;a[b][c]=R;a[d][e]=B;return 1;}

if (a[x][y]==RO&&a[b][c]==BO&&a[d][e]==O)

{a[x][y]=O;a[b][c]=RO;a[d][e]=BO;return 1;}

if (a[x][y]==RO&&a[b][c]==BO&&a[d][e]==0)

{a[x][y]=O;a[b][c]=RO;a[d][e]=B;return 1;}

}

return 0;

}

void all0 (char a[Size][Size])//数组成员归为0

{

int i,j;

for (i=0;i<Size;i++)

for (j=0;j<Size;j++)

a[i][j]=0;

}


Ⅷ 用汇编语言编写一个推箱子游戏

出来了,代码如下:
data segment
car db 2,2,2,2,2,2,2,2,2,2
db 2,2,2,2,2,2,0,0,0,2
db 2,2,2,2,2,2,0,0,0,2
db 2,2,2,2,2,2,0,0,0,2
db 2,2,2,2,2,2,2,2,2,2
db 2,2,2,2,2,2,2,2,2,2
db 0,0,2,0,0,0,0,2,0,0
db 0,2,0,2,0,0,2,0,2,0
db 0,0,2,0,0,0,0,2,0,0
x dw 10
y dw 10
msg db 'car program finish!!$'
speed dw 5
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ax,0a000h
mov es,ax
mov ax,13h
int 10h
call picture
ag: mov ah,7
int 21h
cmp al,'s'
jne ag
start1: in al,60h
cmp al,80h ;if release key
jae keyrelease
cmp al,2 ;1 key
jz upspeed
cmp al,3 ;2 key
jz downspeed
jmp keyrelease
upspeed:
mov si,speed
inc si
mov speed,si
jmp keyrelease
downspeed:
mov si,speed
dec si
mov speed,si
jmp keyrelease
keyrelease:
call clearpicture
mov si,speed
add si,x
mov x,si
call picture
call delay
mov si,x
cmp si,310
jc start1
mov ah,9
mov dx,offset msg
int 21h
mov ah,7
int 21h
mov ax,4c00h
int 21h

picture proc near
mov dx,y
mov bx,0
again: cmp dx,0
je over
add bx,320
dec dx
jmp again
over: mov dx,9
lea si,car
next1: mov cx,10
mov di,x
next: mov al,[si]
mov es:[bx+di],al
inc si
inc di
loop next
add bx,320
dec dx
jne next1
ret
picture endp

clearpicture proc near
mov dx,y
mov bx,0
again2: cmp dx,0
je over2
add bx,320
dec dx
jmp again2
over2: mov dx,9
next12: mov cx,10
mov di,x
next2: mov al,0
mov es:[bx+di],al
inc di
loop next2
add bx,320
dec dx
jne next12
ret
clearpicture endp

delay proc near
push bx
push cx
mov bx,1234
back:
mov cx,66
push ax
wait1:
in al,61h
and al,10h
cmp al,ah
je wait1
mov ah,al
loop wait1
pop ax
dec bx
jne back
pop cx
pop bx
ret
delay endp

code ends
end start

Ⅸ 请问#include <bios.h>,则个是C语言编写推箱子的头文件,用VC++6.0编译会出错,请问怎么解决!!

<bios.h> 这个头文件是TC专用的头文件,VC中没有这个头文件。

你想写推箱子程序,不知道怎么刻画界面的,如果使用VC的对话框等,则有专门接受键盘信息的处理函数。

阅读全文

与怎么用推箱子编译相关的资料

热点内容
mc无敌命令 浏览:85
windows核心编程光盘 浏览:621
美女和程序员相亲视频 浏览:657
你熟悉哪些算法 浏览:770
杭州有什么服务器地址 浏览:1004
为什么大力推行反诈app 浏览:15
win10如何加密系统软件 浏览:19
ipad看扫描pdf 浏览:686
淘宝检测云服务器 浏览:162
孝庄命令鳌拜救康熙 浏览:263
文件压缩还是太大 浏览:6
文件加密器91好破解吗 浏览:136
学生编程思想的培养 浏览:409
新建不了文件夹怎么回事 浏览:271
军地两用人才之友pdf 浏览:601
头条视频算法推荐机制改版 浏览:919
加密的pdf文件怎么打开 浏览:658
如何将数据传到服务器查找服务器读取数据 浏览:1006
怎么知道服务器上是否在运行代码 浏览:857
单片机多联机 浏览:217