


版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
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 歡迎進入推箱子游戲 nntttt 請按 a b c 選擇游 戲nntttt按 d 鍵結束”);in
2、t 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 請重新輸入 :");goto loop1;time(&b);",b-a);printf("nnnntttt 游戲總共用時 %.3d 秒 nttt getch();/ 等待讀取回車符以結束程
3、序void 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= /* 為背景設置初始資料 */'#','#','#','#','#','#','#','#','#','#','#','
4、;#', 3, 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、9;,'#', '#','#', 3 , 0 , 0 , 0 ,'#','#','#', '#','#','#','#','#','#','#','#','#', '#','#','#','#','#','#','#','#',
6、39;#'show(a);/ 調用輸出函數loop:/ 語句標號 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用時 .3d 秒n”,q-p);printf("tttt* 回車重 新選擇
7、*ntttt"); getch();elsetime(&o);if(z='d')return;if(o-p>30)loop1: system("cls");/ 刷屏printf("tttt 時間已過請重新回車選關 !"); int g=getch();if(g=13)/ 判斷是否為回車符return;elsegoto loop1;system("cls");/ 刷屏 show(a);/ 調用輸出函數 goto loop;void map2()time_t p,q,o;time(&p);i
8、nt i=2,j=1,m=1,n=3,t=4,k=6; system("cls");/ 刷屏 system("color 2E");int x=4,y=1;char z,b99= /* 為背景設置初始資料 */'#','#','#','#','#','#','#','#','#','#','#','#', 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 ,'#','#', '#','#'
10、;,'#', 0 , 0 , 5 ,'#','#','#', '#','#','#','#', 0 , 0 ,'#','#','#', '#','#','#','#','#','#','#','#','#'show(b);/ 調用輸出函數loop:/ 語句標號move(b,&am
11、p;x,&y,i,j,m,n,t,k,&z); if(bij='!'&&bmn='!'&&btk='!')system("cls");/ 刷屏show(b);printf("tttt YOU ARE WIN!n"); time(&q);printf("ttttt用時 .3d 秒n”,q-p);printf("tttt* 回車重 新選擇 *ntttt"); getch();elsetime(&o);if(z='
12、;d')return;if(o-p>30)loop1:system("cls");/ 刷屏printf("tttt 時間已過請重新回車選關 !"); int g=getch();if(g=13)/ 判斷是否為回車符return;elsegoto loop1;system("cls");/ 刷屏 show(b);/ 調用輸出函數 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"
13、);/ 刷屏 system("color 2E");int x=3,y=6;char z,c99= /* 為背景設置初始資料 */ '#','#','#','#','#','#','#','#','#', '#','#','#','#','#', 0 , 0 , 0 ,'#', '#', 3 ,'#', 0
14、 , 0 , 0 , 0 , 0 ,'#', '#', 0 , 5 , 0 , 5 ,'#', 1 ,'#','#', '#', 0 , 0 , 0 , 0 , 0 , 5 , 0 ,'#', '#','#', 0 , 0 , 0 , 0 , 0 , 0 ,'#', '#','#', 3 , 0 ,'#', 0 ,'#', 0 ,'#', '#
15、9;,'#','#', 0 , 0 , 0 , 3 ,'#','#', '#','#','#','#','#','#','#','#','#'show(c);/ 調用輸出函數loop:/ 語句標號move(c,&x,&y,i,j,m,n,t,k,&z); if(cij='!'&&cmn='!'&&ctk
16、='!') system("cls");/ 刷屏 show(c);printf("tttt YOU ARE WIN!n"); time(&q);printf("ttttt 用時 .3d 秒n”,q-p); printf("tttt* 回車重 新選擇 *ntttt"); getch();elsetime(&o); if(z='d')return;if(o-p>30) loop1:system("cls");/ 刷屏printf("tttt 時間
17、已過請重新回車選關 !"); int g=getch();if(g=13)/ 判斷是否為回車符return;elsegoto loop1; system("cls");/ 刷屏 show(c);/ 調用輸出函數 goto loop;void show(char b99)printf("tttt* *printf("tttt 推箱子游戲 ");printf("ntttt*n");printf("tttt人:墻: ntttt 箱子:出游戲 ntttt 限時 30 秒!");目的地: ntttt 按d
18、鍵退printf("ntttt*n");int i;int k;for(i=0;i<9;i+)/ 使用循環將地圖轉換輸出printf("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(" ");el
19、seif(bik='!')printf(” O ”);elseprintf("%c ",bik);printf("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()得到上下左右鍵,要調用二次getch(),上鍵72,下鍵80,左鍵75,右鍵 77.if(*t='d')/ 遇到 d 返回if(*t=75)/ 左鍵 if(c
20、*x*y-1='#'|c*x*y-1=5&&c*x*y-2=5|c*x*y-1=5&&c*x*y-2='!')/ 遇到墻或推兩個箱子else if(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;
21、c*x*y=1;c*x*y-1=5;elsec*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='#')/ 推不動箱子 else if(c*x*y-1=cXY|c*x*y-1=cAB |c*x*y-1=cNM)/ 進到目的地 c*x*y=0;*y-=1;c*x*y=1;elseif(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|cN
22、M=5)/ 箱子推到目的地c*x*y-1='!'if(*t=77)/ 右鍵if(c*x*y+1='#'|c*x*y+1=5&&c*x*y+2=5|c*x*y+1=5&&c*x*y+2='!')/ 遇到墻或推兩個箱子elseif(c*x*y+1='!')/ 把箱子推出目的地if(c*x*y+2!=0)else c*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=c
23、XY|c*x*y=cAB |c*x*y=cNM) / 推著箱子離開目的地c*x*y=3;*y+=1;c*x*y=1;c*x*y+1=5;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='#')/ 推不動箱子elseif(c*x*y+1=cXY|c*x*y+1=cAB|c*x*y+1=cNM)/ 進到目的地c*x*y=0;*y+=1;c*x*y=1;elseif(c*x*y=cXY|c*x*y=cAB|c*x*y=cNM) / 離開目的地 c*x*y=3;*y+=1;c*x*y=1;els
24、e / 走到空地c*x*y=0;*y+=1;c*x*y=1;if(cXY=5|cAB=5|cNM=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='!')/ 遇到墻或推兩個箱子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;else if(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;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='#')/ 推不動箱子 elseif(c*x-1*y=cXY|c*x-1*y=cAB|c*x-1*y=c
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 房產買賣合同指南
- 輕鋼別墅銷售合同范本
- 遼寧省葫蘆島市興城市2020-2021學年八年級上學期期末考試物理試題【含答案】
- 駕校教練車租賃合同
- 鋼筋工程分包合同協議書
- 中介銷售合作合同范本2025
- 初中英語教科版(五四學制)九年級上冊Unit 4 Growing Good Corn一等獎教案
- 腸梗阻患者護理查房
- 11變廢為寶有妙招 公開課一等獎創新教學設計 (表格式)
- 2《共建美好集體》表格式公開課一等獎創新教學設計
- 高考英語核心詞匯1000個
- 美術四年級國測模擬題(滿分50分)附有答案
- 2024年度保密教育線上培訓考試題庫新版
- 快遞驛站承包協議書
- 人教版語文七年級下生字詞練習看拼音寫詞語
- 地坪漆專項施工方案及流程
- 病原微生物實驗活動風險評估表
- 水工藝與工程新技術智慧樹知到期末考試答案章節答案2024年西安建筑科技大學
- 小學三年級下冊 譯林版英語:期中復習重點整合
- 2024年輔警招聘考試試題庫含完整答案(各地真題)
- 電纜敷設施工技術經驗分享與案例分析重難點施工技術分享與討論
評論
0/150
提交評論