c語(yǔ)言推箱子代碼_第1頁(yè)
c語(yǔ)言推箱子代碼_第2頁(yè)
c語(yǔ)言推箱子代碼_第3頁(yè)
c語(yǔ)言推箱子代碼_第4頁(yè)
c語(yǔ)言推箱子代碼_第5頁(yè)
已閱讀5頁(yè),還剩19頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、#include <stdio.h>#include <stdlib.h>void map1();void map2();void map3();void show();void move();void main(int argc,char*argv)time_t a,b;time(&a);system("color 1E");loop1:system("cls");/刷屏printf("nnnnnntttt歡迎進(jìn)入推箱子游戲nntttt 請(qǐng)按a b c選擇游戲nntttt 按 d 鍵 結(jié)束");int

2、 t=getch();if(t='d')printf("nttt ");elseif(t='a')map1();goto loop1;if(t='b')map2();goto loop1;if(t='c')map3();goto loop1;elseprintf("nntttt 請(qǐng)重新輸入:");goto loop1;time(&b);printf("nnnntttt 游戲總共用時(shí)%.3d秒nttt ",b-a);getch();/等待讀取回車符以結(jié)束程序void

3、 map1()time_t p,q,o;time(&p);int i=4,j=4,m=6,n=2,t=1,k=3;system("cls");/刷屏system("color 2E");int x=1,y=7;char z,a99= /*為背景設(shè)置初始資料*/'#','#','#','#','#','#','#','#','#','#','#','#', 3

4、, 0 , 0 , 0 , 1 ,'#','#','#', 0 , 0 , 0 ,'#', 0 ,'#','#','#', 0 , 0 ,'#', 0 , 0 , 5 , 0 ,'#','#', 0 , 5 , 5 , 3 , 0 , 0 , 0 ,'#','#','#', 0 ,'#', 0 , 0 ,'#','#','#'

5、,'#','#', 3 , 0 , 0 , 0 ,'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'show(a);

6、/調(diào)用輸出函數(shù)loop:/語(yǔ)句標(biāo)號(hào)move(a,&x,&y,i,j,m,n,t,k,&z);if(aij='!'&&amn='!'&&atk='!')system("cls");/刷屏show(a);printf("tttt YOU ARE WIN!n");time(&q);printf("ttttt 用時(shí)%.3d秒n",q-p);printf("tttt*回車重 新選擇*ntttt");getch();

7、elsetime(&o);if(z='d')return;if(o-p>30)loop1:system("cls");/刷屏printf("tttt時(shí)間已過(guò)請(qǐng)重新回車選關(guān)!");int g=getch();if(g=13)/判斷是否為回車符return;elsegoto loop1;system("cls");/刷屏show(a);/調(diào)用輸出函數(shù)goto loop;void map2() time_t p,q,o;time(&p);int i=2,j=1,m=1,n=3,t=4,k=6;syste

8、m("cls");/刷屏system("color 2E");int x=4,y=1;char z,b99= /*為背景設(shè)置初始資料*/'#','#','#','#','#','#','#','#','#','#','#','#', 3 , 0 ,'#','#','#','#','#',

9、 3 ,'#', 0 , 0 , 0 , 0 ,'#','#','#', 0 , 5 , 0 ,'#','#', 0 , 0 ,'#','#', 1 , 0 , 5 , 0 , 0 , 3 , 0 ,'#','#', 0 , 0 , 0 , 0 , 0 , 0 ,'#','#','#','#','#', 0 , 0 , 5 ,'#','

10、;#','#','#','#','#','#', 0 , 0 ,'#','#','#','#','#','#','#','#','#','#','#','#'show(b);/調(diào)用輸出函數(shù)loop:/語(yǔ)句標(biāo)號(hào)move(b,&x,&y,i,j,m,n,t,k,&z);if(bij='!&#

11、39;&&bmn='!'&&btk='!')system("cls");/刷屏show(b);printf("tttt YOU ARE WIN!n");time(&q);printf("ttttt 用時(shí)%.3d秒n",q-p);printf("tttt*回車重 新選擇*ntttt");getch();elsetime(&o);if(z='d')return;if(o-p>30)loop1:system("

12、cls");/刷屏printf("tttt時(shí)間已過(guò)請(qǐng)重新回車選關(guān)!");int g=getch();if(g=13)/判斷是否為回車符return;elsegoto loop1;system("cls");/刷屏show(b);/調(diào)用輸出函數(shù)goto loop;void map3()time_t p,q,o;time(&p);int i=2,j=1,m=6,n=2,t=7,k=6;system("cls");/刷屏system("color 2E");int x=3,y=6;char z,c99=

13、 /*為背景設(shè)置初始資料*/'#','#','#','#','#','#','#','#','#','#','#','#','#','#', 0 , 0 , 0 ,'#','#', 3 ,'#', 0 , 0 , 0 , 0 , 0 ,'#','#', 0 , 5 , 0 , 5 ,'#

14、', 1 ,'#','#','#', 0 , 0 , 0 , 0 , 0 , 5 , 0 ,'#','#','#', 0 , 0 , 0 , 0 , 0 , 0 ,'#','#','#', 3 , 0 ,'#', 0 ,'#', 0 ,'#','#','#','#', 0 , 0 , 0 , 3 ,'#','#',&#

15、39;#','#','#','#','#','#','#','#','#'show(c);/調(diào)用輸出函數(shù)loop:/語(yǔ)句標(biāo)號(hào)move(c,&x,&y,i,j,m,n,t,k,&z);if(cij='!'&&cmn='!'&&ctk='!')system("cls");/刷屏show(c);printf("tttt YOU ARE

16、 WIN!n");time(&q);printf("ttttt 用時(shí)%.3d秒n",q-p);printf("tttt*回車重 新選擇*ntttt");getch();elsetime(&o);if(z='d')return;if(o-p>30)loop1:system("cls");/刷屏printf("tttt時(shí)間已過(guò)請(qǐng)重新回車選關(guān)!");int g=getch();if(g=13)/判斷是否為回車符return;elsegoto loop1;system(&qu

17、ot;cls");/刷屏show(c);/調(diào)用輸出函數(shù)goto loop;void show(char b99)printf("tttt*n");printf("tttt 推箱子游戲 ");printf("ntttt*n");printf("tttt 人: 墻:ntttt 箱子: 目的地:ntttt 按 d 鍵 退出游戲ntttt 限時(shí)30秒!");printf("ntttt*n");int i;int k;for(i=0;i<9;i+) /使用循環(huán)將地圖轉(zhuǎn)換輸出printf(&

18、quot;tttt ");for(k=0;k<9;k+)if(bik='#')printf("");elseif(bik=3)printf("");elseif(bik=5)printf("");elseif(bik=1)printf("");elseif(bik=0)printf(" ");elseif(bik='!') printf(""); elseprintf("%c ",bik); printf(&

19、quot;n"); printf("tttt*n");void move(char c99,int *x,int *y,int X,int Y,int A,int B,int N,int M,char *t) *t=getch();/用getch()得到上下左右鍵,要調(diào)用二次getch(),上鍵72,下鍵80,左鍵75,右鍵77. if(*t='d')/遇到d返回if(*t=75)/左鍵if(c*x*y-1='#'|c*x*y-1=5&&c*x*y-2=5 |c*x*y-1=5&&c*x*y-2=&#

20、39;!')/遇到墻或推兩個(gè)箱子elseif(c*x*y-1='!')/把箱子推出目的地if(c*x*y-2!=0)elsec*x*y=0;*y-=1;c*x*y=1;c*x*y-1=5;elseif(c*x*y-1=5&&c*x*y-2!='#')/推箱子 if(c*x*y=cXY|c*x*y=cAB |c*x*y=cNM) /推著箱子離開目的地 c*x*y=3; *y-=1; c*x*y=1; c*x*y-1=5; else c*x*y=0; *y-=1; c*x*y=1; c*x*y-1=5; else if(c*x*y-1=5&a

21、mp;&c*x*y-2='#')/推不動(dòng)箱子 else if(c*x*y-1=cXY|c*x*y-1=cAB |c*x*y-1=cNM)/進(jìn)到目的地 c*x*y=0; *y-=1; c*x*y=1; else if(c*x*y=cXY|c*x*y=cAB |c*x*y=cNM) /離開目的地 c*x*y=3; *y-=1; c*x*y=1; else /走到空地 c*x*y=0; *y-=1; c*x*y=1; if(cXY=5|cAB=5|cNM=5)/箱子推到目的地 c*x*y-1='!' if(*t=77)/右鍵if(c*x*y+1='#&

22、#39;|c*x*y+1=5&&c*x*y+2=5 |c*x*y+1=5&&c*x*y+2='!')/遇到墻或推兩個(gè)箱子elseif(c*x*y+1='!')/把箱子推出目的地if(c*x*y+2!=0)elsec*x*y=0;*y+=1;c*x*y=1;c*x*y+1=5;elseif(c*x*y+1=5&&c*x*y+2!='#')/推箱子 if(c*x*y=cXY|c*x*y=cAB |c*x*y=cNM) /推著箱子離開目的地 c*x*y=3; *y+=1; c*x*y=1; c*x*y+1

23、=5; else c*x*y=0; *y+=1; c*x*y=1; c*x*y+1=5; else if(c*x*y+1=5&&c*x*y+2='#')/推不動(dòng)箱子 else if(c*x*y+1=cXY|c*x*y+1=cAB |c*x*y+1=cNM)/進(jìn)到目的地 c*x*y=0; *y+=1; c*x*y=1; else if(c*x*y=cXY|c*x*y=cAB |c*x*y=cNM) /離開目的地 c*x*y=3; *y+=1; c*x*y=1; else /走到空地 c*x*y=0; *y+=1; c*x*y=1; if(cXY=5|cAB=5|c

24、NM=5)/箱子推到目的地 c*x*y+1='!' if(*t=72)/上鍵if(c*x-1*y='#'|c*x-1*y=5&&c*x-2*y=5 |c*x-1*y=5&&c*x-2*y='!')/遇到墻或推兩個(gè)箱子elseif(c*x-1*y='!')/把箱子推出目的地if(c*x-2*y!=0)elsec*x*y=0;*x-=1;c*x*y=1;c*x-1*y=5;elseif(c*x-1*y=5&&c*x-2*y!='#')/推箱子 if(c*x*y=cXY|c*x*y=cAB |c*x*y=cNM) /推著箱子離開目的地 c*x*y=3; *x-=1; c*x*y=1; c*x-1*y=5; else c*x*y=0; *x-=1; c*x*y=1; c*x-1*y=5; else if(c*x-1*y=5&&c*x-2*y='#')/推不動(dòng)箱子 else if(c*x-1*y=cXY|c*x-1*y=cAB |c*x-1*y=cNM)/進(jìn)到目的地 c*x*y=0; *x-=1; c*x*y

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論