1、C 语言编写的推箱子游戏C 语言编写的推箱子游戏.txt爱尔兰一个不离婚的国家,一个一百年的约定。难过了,不要告诉别人,因为别人不在乎。 真话假话都要猜,这就是现在的社会。 C 语言编写的推箱子游戏看到别人用 C 编出了俄罗斯方块,心想:简直不可思意。心里满是佩服,跟本没想到 C 还能有这么搞法,心里非常兴奋,我这个人就是爱编些小东西(大东西编不来),感觉有意思的都总想动手搞搞,以前用VB做过推箱子游戏,用C还没做过,当时也觉得用C不可能,觉得要是能那是太难了,现在看了别人用C对图形的处理,慢慢觉得推箱子游戏自己可以把它写出来,于是就开始编写推箱子游戏(自觉得伟大的工程),今天写完,心里非常兴
2、奋,迫不及待的就往论坛里发,想炫耀一下,满足下虚荣心,唉!我这人就是这样,虚荣的很。大家支持一下,有夸奖才有动力。呵呵!程序在TC2.0、Win-TC下测试通过。程序代码:#include #include #include #include #include #define SIZE 20#define KEY_UP 0x4800#define KEY_DOWN 0x5000#define KEY_LEFT 0x4b00#define KEY_RIGHT 0x4d00#define KEY_ESC 0x011b#define Re 0x1372int Step=0,right_Step,to
3、p_Step;void cheshi(int a6,int n,int m)int i,j;for(i=0;in;i+) for(j=0;jm;j+) printf(%d ,aij); printf(n); void Coloring(int x,int y,int subscript) switch(subscript) case 0: setfillstyle(1,DARKGRAY); break; case 1: setfillstyle(6,YELLOW); break; case 2: setfillstyle(8,DARKGRAY); break; case 3: setfills
4、tyle(1,CYAN); break; case 4: setfillstyle(1,RED); break; case 5: setfillstyle(1,CYAN); break; case 6: setfillstyle(1,RED); break; bar(x,y,x+SIZE,y+SIZE);void display(int guan6,int imax,int jmax) int gdriver = DETECT, gmode, errorcode; int left, top, right, bottom,x,y; int i,j; initgraph(&gdriver, &g
5、mode, ); errorcode = graphresult(); if (errorcode != grOk) printf(Graphics error: %sn, grapherrormsg(errorcode); printf(Press any key to halt:); getch(); exit(1); left=getmaxx()/2-jmax*SIZE+jmax*2+2; top=getmaxy()/2-(imax/2*SIZE)+(imax/2+4); right=left+jmax*SIZE+jmax*2+2; bottom=getmaxy()/2+(imax-im
6、ax/2)*SIZE)+(imax-imax/2)+4); right_Step=right; top_Step=top; rectangle(left,top,right,bottom); for(i=0;iimax;i+) for(j=0;jjmax;j+) x=left+(j+1)*2+j*SIZE; y=top+(i+1)*2+i*SIZE; Coloring(x,y,guanij); setcolor(YELLOW); outtextxy(left,top-20,UserYuH:BOX); setcolor(WHITE); outtextxy(right+10,top,Guan:);
7、 outtextxy(right+10,top+20,Step:); rectangle(left,bottom+4,left+82,bottom+20); settextjustify(LEFT_TEXT,TOP_TEXT); outtextxy(left+4,bottom+8,R:refresh); rectangle(left+86,bottom+4,left+162,bottom+20); settextjustify(LEFT_TEXT,TOP_TEXT); outtextxy(left+92,bottom+8,Esc:exit);void CopyGuan(int guan6,in
8、t guan_all6,int imax,int jmax)int i,j; for(i=0;iimax;i+) for(j=0;j0)i-; else break; if(guanij=0) if(guan*irj=6) guanij=4; guan*irj=2; else guan*irj=0; guanij=4; Coloring(left+(j+1)*2+j*SIZE,top+(i+1)*2+i*SIZE,guanij); Coloring(left+(j+1)*2+j*SIZE,top+(*ir+1)*2+*ir*SIZE,guan*irj); *ir=i; Step+; else
9、if(guanij=3) if(i0 & (guani-1j=0|guani-1j=2) if(guani-1j=0) guani-1j=3; else guani-1j=5; (*fulfil)+; guanij=0; Coloring(left+(j+1)*2+j*SIZE,top+(i-1)+1)*2+(i-1)*SIZE,guani-1j); Coloring(left+(j+1)*2+j*SIZE,top+(i+1)*2+i*SIZE,guanij); Step+; else if(guanij=5) if(i0 & (guani-1j=0|guani-1j=2) if(guani-
10、1j=0) guani-1j=3; else guani-1j=5; (*fulfil)+; guanij=2; Coloring(left+(j+1)*2+j*SIZE,top+(i-1)+1)*2+(i-1)*SIZE,guani-1j); Coloring(left+(j+1)*2+j*SIZE,top+(i+1)*2+i*SIZE,guanij); Step+; (*fulfil)-; else if(guanij=2) guanij=6; if(guan*irj=4) guan*irj=0; else guan*irj=2; Coloring(left+(j+1)*2+j*SIZE,
11、top+(i+1)*2+i*SIZE,guanij); Coloring(left+(j+1)*2+j*SIZE,top+(*ir+1)*2+*ir*SIZE,guan*irj); *ir=i; Step+; break; case 2: if(iimax-1)i+; else break; if(guanij=0) if(guan*irj=6) guanij=4; guan*irj=2; else guan*irj=0; guanij=4; Coloring(left+(j+1)*2+j*SIZE,top+(i+1)*2+i*SIZE,guanij); Coloring(left+(j+1)
12、*2+j*SIZE,top+(*ir+1)*2+*ir*SIZE,guan*irj); *ir=i; Step+; else if(guanij=3) if(iimax-1 & (guani+1j=0|guani+1j=2) if(guani+1j=0) guani+1j=3; else guani+1j=5; (*fulfil)+; guanij=0; Coloring(left+(j+1)*2+j*SIZE,top+(i+1)+1)*2+(i+1)*SIZE,guani+1j); Coloring(left+(j+1)*2+j*SIZE,top+(i+1)*2+i*SIZE,guanij)
13、; Step+; else if(guanij=5) if(i0)j-; else break; if(guanij=0) if(guani*jr=6) guanij=4; guani*jr=2; else guani*jr=0; guanij=4; Coloring(left+(j+1)*2+j*SIZE,top+(i+1)*2+i*SIZE,guanij); Coloring(left+(*jr+1)*2+*jr*SIZE,top+(i+1)*2+i*SIZE,guani*jr); *jr=j; Step+; else if(guanij=3) if(j0 & (guanij-1=0|gu
14、anij-1=2) if(guanij-1=0) guanij-1=3; else guanij-1=5; (*fulfil)+; guanij=0; Coloring(left+(j-1)+1)*2+(j-1)*SIZE,top+(i+1)*2+i*SIZE,guanij-1); Coloring(left+(j+1)*2+j*SIZE,top+(i+1)*2+i*SIZE,guanij); Step+; else if(guanij=5) if(j0 & (guanij-1=0|guanij-1=2) if(guanij-1=0) guanij-1=3; else guanij-1=5;
15、(*fulfil)+; guanij=2; Coloring(left+(j-1)+1)*2+(j-1)*SIZE,top+(i+1)*2+i*SIZE,guanij-1); Coloring(left+(j+1)*2+j*SIZE,top+(i+1)*2+i*SIZE,guanij); Step+; (*fulfil)-; else if(guanij=2) guanij=6; if(guani*jr=4) guani*jr=0; else guani*jr=2; Coloring(left+(j+1)*2+j*SIZE,top+(i+1)*2+i*SIZE,guanij); Colorin
16、g(left+(*jr+1)*2+*jr*SIZE,top+(i+1)*2+i*SIZE,guani*jr); *jr=j; Step+; break; case 4: if(jjmax-1)j+; else break; if(guanij=0) if(guani*jr=6) guanij=4; guani*jr=2; else guani*jr=0; guanij=4; Coloring(left+(j+1)*2+j*SIZE,top+(i+1)*2+i*SIZE,guanij); Coloring(left+(*jr+1)*2+*jr*SIZE,top+(i+1)*2+i*SIZE,gu
17、ani*jr); *jr=j; Step+; else if(guanij=3) if(jjmax-1 & (guanij+1=0|guanij+1=2) if(guanij+1=0) guanij+1=3; else guanij+1=5; (*fulfil)+; guanij=0; Coloring(left+(j+1)+1)*2+(j+1)*SIZE,top+(i+1)*2+i*SIZE,guanij+1); Coloring(left+(j+1)*2+j*SIZE,top+(i+1)*2+i*SIZE,guanij); Step+; else if(guanij=5) if(jjmax-1 & (guanij+1=0|guanij+1=2) if(guanij+1=0) guanij+1=3; else guanij+1=5; (*fulfil)+; guanij=2; Coloring(left+(j+1)+1)*2+(j+1)*SIZE,top+(i+1)*2+i*SIZE,guanij+1); Coloring(left+(j+1)*2+j*SIZE,top+(i+1)*2+i*SIZE,guanij); Step+;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1