C 语言编写的《推箱子》游戏Word格式.docx

上传人:b****6 文档编号:20732094 上传时间:2023-01-25 格式:DOCX 页数:22 大小:17.92KB
下载 相关 举报
C 语言编写的《推箱子》游戏Word格式.docx_第1页
第1页 / 共22页
C 语言编写的《推箱子》游戏Word格式.docx_第2页
第2页 / 共22页
C 语言编写的《推箱子》游戏Word格式.docx_第3页
第3页 / 共22页
C 语言编写的《推箱子》游戏Word格式.docx_第4页
第4页 / 共22页
C 语言编写的《推箱子》游戏Word格式.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

C 语言编写的《推箱子》游戏Word格式.docx

《C 语言编写的《推箱子》游戏Word格式.docx》由会员分享,可在线阅读,更多相关《C 语言编写的《推箱子》游戏Word格式.docx(22页珍藏版)》请在冰豆网上搜索。

C 语言编写的《推箱子》游戏Word格式.docx

#defineKEY_DOWN0x5000

#defineKEY_LEFT0x4b00

#defineKEY_RIGHT0x4d00

#defineKEY_ESC0x011b

#defineRe0x1372

intStep=0,right_Step,top_Step;

voidcheshi(inta[][6],intn,intm)

{

inti,j;

for(i=0;

i<

n;

i++)

{

for(j=0;

j<

m;

j++)

printf("

%d"

a[i][j]);

\n"

);

}

}

voidColoring(intx,inty,intsubscript)

switch(subscript)

case0:

setfillstyle(1,DARKGRAY);

break;

case1:

setfillstyle(6,YELLOW);

case2:

setfillstyle(8,DARKGRAY);

case3:

setfillstyle(1,CYAN);

case4:

setfillstyle(1,RED);

case5:

case6:

bar(x,y,x+SIZE,y+SIZE);

voiddisplay(intguan[][6],intimax,intjmax)

intgdriver=DETECT,gmode,errorcode;

intleft,top,right,bottom,x,y;

inti,j;

initgraph(&

gdriver,&

gmode,"

"

errorcode=graphresult();

if(errorcode!

=grOk)

Graphicserror:

%s\n"

grapherrormsg(errorcode));

Pressanykeytohalt:

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-imax/2)*SIZE)+((imax-imax/2)+4));

right_Step=right;

top_Step=top;

rectangle(left,top,right,bottom);

 

for(i=0;

imax;

jmax;

x=left+(j+1)*2+j*SIZE;

y=top+(i+1)*2+i*SIZE;

Coloring(x,y,guan[i][j]);

setcolor(YELLOW);

outtextxy(left,top-20,"

UserYuH:

BOX"

setcolor(WHITE);

outtextxy(right+10,top,"

Guan:

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);

outtextxy(left+92,bottom+8,"

Esc:

exit"

voidCopyGuan(intguan[][6],intguan_all[][6],intimax,intjmax)

guan[i][j]=guan_all[i][j];

voidselect_guan(intguan_all[][6],intguan[][6],intsubi_j[],intijmax[],intguan_num,int*fulfil)

switch(guan_num)

*fulfil=2;

subi_j[0]=2,subi_j[1]=0;

ijmax[0]=6,ijmax[1]=4;

CopyGuan(guan,guan_all,ijmax[0],ijmax[1]);

ijmax[0]=5,ijmax[1]=5;

*fulfil=1;

subi_j[0]=3,subi_j[1]=3;

ijmax[0]=6,ijmax[1]=6;

*fulfil=0;

subi_j[0]=1,subi_j[1]=1;

subi_j[0]=4,subi_j[1]=2;

ijmax[0]=5,ijmax[1]=6;

subi_j[0]=0,subi_j[1]=4;

ijmax[0]=6,ijmax[1]=5;

case7:

subi_j[0]=2,subi_j[1]=4;

case8:

case9:

subi_j[0]=3,subi_j[1]=1;

ijmax[0]=4,ijmax[1]=6;

case10:

case11:

subi_j[0]=4,subi_j[1]=1;

case12:

subi_j[0]=0,subi_j[1]=2;

case13:

subi_j[0]=2,subi_j[1]=3;

case14:

subi_j[0]=3,subi_j[1]=0;

case15:

subi_j[0]=0,subi_j[1]=3;

case16:

case17:

subi_j[0]=3,subi_j[1]=5;

case18:

subi_j[0]=0,subi_j[1]=1;

case19:

subi_j[0]=5,subi_j[1]=4;

case20:

subi_j[0]=1,subi_j[1]=4;

CopyGuan(guan,guan_all,ijmax[0],ijmax[1]);

voidEixt()

exit(0);

voidMove(intpoint,intguan[][6],intsubi_j[],intimax,intjmax,int*fulfil)

inti,j,*ir,*jr,left,top;

left=getmaxx()/2-jmax*SIZE+jmax*2+2;

top=getmaxy()/2-((imax/2*SIZE)+(imax/2+4));

ir=&

subi_j[0],jr=&

subi_j[1];

i=*ir,j=*jr;

switch(point)

if(i>

0)i--;

elsebreak;

if(guan[i][j]==0)

if(guan[*ir][j]==6)

guan[i][j]=4;

guan[*ir][j]=2;

else

guan[*ir][j]=0;

Coloring(left+(j+1)*2+j*SIZE,top+(i+1)*2+i*SIZE,guan[i][j]);

Coloring(left+(j+1)*2+j*SIZE,top+(*ir+1)*2+*ir*SIZE,guan[*ir][j]);

*ir=i;

Step++;

elseif(guan[i][j]==3)

0&

&

(guan[i-1][j]==0||guan[i-1][j]==2))

if(guan[i-1][j]==0)

guan[i-1][j]=3;

guan[i-1][j]=5;

(*fulfil)++;

guan[i][j]=0;

Coloring(left+(j+1)*2+j*SIZE,top+((i-1)+1)*2+(i-1)*SIZE,guan[i-1][j]);

elseif(guan[i][j]==5)

guan[i][j]=2;

(*fulfil)--;

elseif(guan[i][j]==2)

guan[i][j]=6;

if(guan[*ir][j]==4)

if(i<

imax-1)i++;

imax-1&

(guan[i+1][j]==0||guan[i+1][j]==2))

if(guan[i+1][j]==0)

guan[i+1][j]=3;

guan[i+1][j]=5;

Coloring(left+(j+1)*2+j*SIZE,top+((i+1)+1)*2+(i+1)*SIZE,guan[i+1][j]);

if(guan[*ir][j]=4)

if(j>

0)j--;

if(guan[i][*jr]==6)

guan[i][*jr]=2;

guan[i][*jr]=0;

Coloring(left+(*jr+1)*2+*jr*SIZE,top+(i+1)*2+i*SIZE,guan[i][*jr]);

*jr=j;

(guan[i][j-1]==0||guan[i][j-1]==2))

if(guan[i][j-1]==0)

guan[i][j-1]=3;

guan[i][j-1]=5;

Coloring(left+((j-1)+1)*2+(j-1)*SIZE,top+(i+1)*2+i*SIZE,guan[i][j-1]);

if(guan[i][*jr]==4)

if(j<

jmax-1)j++;

jmax-1&

(guan[i][j+1]==0||guan[i][j+1]==2))

if(guan[i][j+1]==0)

guan[i][j+1]=3;

guan[i][j+1]=5;

Coloring(left+((j+1)+1)*2+(j+1)*SIZE,top+(i+1)*2+i*SIZE,guan[i][j+1]);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1