资源描述:
《c语言课程设计 推箱子new》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#include#include#include#include#includetypedefstructwiner{intx,y;structwiner*p;}winer;charstatus[20][20];charfar*printScreen=(charfar*)0xB8000000;voidputoutChar(inty,intx,charch,charfc,charbc);voidprintWall(intx,inty);voidprintBox(intx,inty
2、);voidprintBoxDes(intx,inty);voidprintDestination(intx,inty);voidprintDestination1(intx,inty,winer**win,winer**pw);voidprintMan(intx,inty);voidinit();winer*initStep1();winer*initStep2();winer*initStep3();winer*initStep4();voidmoveBoxSpacetoSpace(intx,inty,chara);voidmoveBoxDestoSpace(intx,inty,chara
3、);voidmoveBoxSpacetoDes(intx,inty,chara);voidmoveBoxDestoDes(intx,inty,chara);intjudge(intx,inty);voidmove(intx,inty,chara);voidreset(inti);voidputoutChar(inty,intx,charch,charfc,charbc){printScreen[(x*160)+(y<<1)+0]=ch;printScreen[(x*160)+(y<<1)+1]=(bc*16)+fc;}voidprintWall(intx,inty){putoutChar(y-
4、1,x-1,219,GREEN,BLACK);status[x][y]='w';}voidprintBox(intx,inty){putoutChar(y-1,x-1,10,WHITE,BLACK);status[x][y]='b';}voidprintDestination1(intx,inty,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
5、=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;}}voidprintDestination(intx,inty){putoutChar(y-1,x-1,003,YELLOW,BLACK);status[x][y]='m';}voidprintMan(intx,inty){gotoxy(y,x);_AL=02;_CX=01;_AH=0xa;geninterrupt(0x10);}voidprintBoxDes(in
6、tx,inty){putoutChar(y-1,x-1,10,YELLOW,BLACK);status[x][y]='i';}voidinit(){inti,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("Welcometotheboxworld!");gotoxy(40,6);printf("Youcanuseup,down,left,");gotoxy(40,8);printf("rightkeytocontrolit,or");go
7、toxy(40,10);printf("youcanpressEsctoquitit.");gotoxy(40,12);printf("Pressspacetoresetthegame.");gotoxy(40,14);printf("Wishyouhaveagoodtime!");gotoxy(40,16);printf("April,2007");}winer*initStep1(){intx