资源描述:
《c语言课程设计 推箱子》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
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);
2、voidprintWall(intx,inty);voidprintBox(intx,inty);voidprintBoxDes(intx,inty);voidprintDestination(intx,inty);voidprintDestination1(intx,inty,winer**win,winer**pw);voidprintMan(intx,inty);voidinit();winer*initStep1();winer*initStep2();winer*initStep3();wi
3、ner*initStep4();voidmoveBoxSpacetoSpace(intx,inty,chara);voidmoveBoxDestoSpace(intx,inty,chara);voidmoveBoxSpacetoDes(intx,inty,chara);voidmoveBoxDestoDes(intx,inty,chara);intjudge(intx,inty);voidmove(intx,inty,chara);voidreset(inti);voidputoutChar(inty
4、,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-1,x-1,219,GREEN,BLACK);status[x][y]='w';}voidprintBox(intx,inty){putoutChar(y-1,x-1,10,WHITE,BLACK);status[x][y]
5、='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=x;(*pw)->y=y;(*pw)->p=NULL;}else{qw=(winer*)malloc(sizeof(winer)
6、);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(intx,inty){putoutCha
7、r(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
8、("rightkeytocontrolit,or");gotoxy(40,10);printf("youcanpressEsctoquitit.");gotoxy(40,12);printf("Pressspacetoresetthegame.");gotoxy(40,14);printf("Wishyouhaveagoodtime!");gotoxy(40,16);printf("April,2007");}winer*initStep1(){intx