




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
1、package s1java.xmal1;public class Map int map = new int100; /對戰(zhàn)地圖int luckyTurn = 6, 23, 40, 55, 69, 83; /幸運輪盤 int landMine = 5, 13, 17, 33, 38, 50, 64, 80, 94; /地雷位置int pause = 9, 27, 60, 93; /暫停int timeTunnel = 20, 25, 45, 63, 72, 88, 90; /時空隧道 /* * 生成地圖: * 關(guān)卡代號為:1:幸運輪盤 2:地雷 3: 暫停 4:時空隧道 0:普通 */ pu
2、blic void createMap() int i = 0; /在對戰(zhàn)地圖上設置幸運輪盤 for(i = 0; i luckyTurn.length; i+) mapluckyTurni = 1; /添加代碼實現(xiàn)在對戰(zhàn)地圖上設置地雷 for(i = 0; i landMine.length; i+) maplandMinei = 2; /添加代碼實現(xiàn)在對戰(zhàn)地圖上設置暫停 for(i = 0; i pause.length; i+ ) mappausei = 3; /添加代碼實現(xiàn)在對戰(zhàn)地圖上設置時空隧道 for(i = 0; i timeTunnel.length; i+) maptimeT
3、unneli = 4; /* * 顯示地圖關(guān)卡對應的圖形 * param i 地圖當前位置的關(guān)卡代號 * param index 當前地圖位置編號 * param playerPos1 玩家1的當前位置 * param playerPos2 玩家2的當前位置 * return 地圖當前位置的對應圖片 */ public String getGraph(int i, int index, int playerPos1, int playerPos2) String graph = ; if(playerPos1=index&index=playerPos2) graph=; else if(pl
4、ayerPos1=index) graph=; else if(playerPos2=index) graph=; else switch(i) case 1: graph=; break; case 2: graph=; break; case 3: graph=; break; case 4: graph=; break; default: graph=; /添加代碼 return graph; /* * 輸出地圖的奇數(shù)行(第1、3行) * param start 輸出的起始點在地圖上的位置 * param end 輸出的結(jié)束點在地圖上的位置 * param playerPos1 玩家1的
5、當前位置 * param playerPos2 玩家2的當前位置 */ public void showLine1(int start, int end, int playerPos1, int playerPos2) /添加代碼 for(int i = start; i = start; i- ) /* * 輸出地圖的右豎列 * param start 輸出的起始點在地圖上的位置 * param end 輸出的結(jié)束點在地圖上的位置 * param playerPos1 玩家1的當前位置 * param playerPos2 玩家2的當前位置 */ public void showRLine(
6、int start, int end, int playerPos1, int playerPos2) for(int i = start; i 0; j-) /輸出29個空格 /* * 輸出地圖的左豎列 * param start 輸出的起始點在地圖上的位置 * param end 輸出的結(jié)束點在地圖上的位置 * param playerPos1 玩家1的當前位置 * param playerPos2 玩家2的當前位置 */ public void showLLine(int start, int end, int playerPos1, int playerPos2) /添加代碼 for(
7、int i = start; i= end; i+) /* * 顯示對戰(zhàn)地圖 * param playerPos1 玩家1的當前位置 * param playerPos2 玩家2的當前位置 */ public void showMap(int playerPos1, int playerPos2) /顯示地圖第一行 /換行 /顯示地圖右豎行 /顯示地圖第二行 /換行 /顯示地圖左豎行 /顯示地圖第3行 showLine1(0, 30, playerPos1, playerPos2); showRLine(31, 34, playerPos1, playerPos2); showLine2(35
8、, 65, playerPos1, playerPos2); showLLine(66, 68, playerPos1, playerPos2); showLine1(69, 99, playerPos1, playerPos2); package s1java.xmal1;public class Game /聲明地圖Map map; /聲明對戰(zhàn)中玩家1的當前位置int playerPos1; /聲明對戰(zhàn)中玩家2的當前位置int playerPos2; /聲明走或停標識設置 String goAndStop=new String2; /聲明對戰(zhàn)角色 String playerName=new
9、 String2; /* * 初始化游戲的一局 */ public void init() /創(chuàng)建Map對象 map = new Map(); /生成地圖 map.createMap(); /設置玩家1起始位置 playerPos1=0; /設置玩家2起始位置 playerPos2=0; /記錄玩家1下一次走或停 goAndStop0=on; /設置玩家2下一次走或停 goAndStop1=on; /* * 開始游戲 */ public void start() /調(diào)用初始化方法 init(); /顯示游戲界面);nnnn); /角色設置 /開始游戲 Scanner in=new Scanne
10、r(System.in); int role=in.nextInt(); setRole(1, role); role=in.nextInt(); setRole(2, role); play(); /* * 設置對戰(zhàn)角色 * param no 玩家次序 1:玩家1 2:玩家2 * param role 角色代號 */ public void setRole(int no, int role) switch(role) case 1: playerNameno-1 = 戴高樂; break; case 2: /設置玩家名稱為艾森豪威爾 playerNameno-1 = 艾森豪威爾; break
11、; case 3: /設置玩家名稱為麥克阿瑟 playerNameno-1 = 麥克阿瑟; break; case 4: /設置玩家名稱為巴頓 playerNameno-1 = 巴頓; break; default: break; /* * 兩人對戰(zhàn)玩法 */ public void play() /顯示對戰(zhàn)雙方士兵樣式 /顯示對戰(zhàn)地圖 暫停 幸運輪盤 地雷 時空隧道 普通n); map.showMap(playerPos1, playerPos2); /游戲開始 int step; /存儲骰子數(shù)目 while(playerPos1 99 & playerPos2 = 99) return 9
12、9; Scanner input = new Scanner(System.in); switch(map.mapposition) /根據(jù)地圖中的關(guān)卡代號進行判斷 case 0: /走到普通格 if(no=1&playerPos2=position) /添加條件:玩家1與對方騎兵相遇 /添加代碼實現(xiàn):踩到對方,對方回到起點 playerPos2=0; if(no=2&playerPos1=position) /添加條件:玩家2與對方騎兵相遇 /添加代碼實現(xiàn):踩到對方,對方回到起點 playerPos1=0; break; case 1: /幸運輪盤歡迎進入幸運輪盤); int choice
13、= input.nextInt(); int temp; /交換時的臨時變量 switch(choice) case 1: /交換位置 if(no = 1) /添加代碼實現(xiàn)交換:position與playerPos2數(shù)值互換 temp=position; position=playerPos2; playerPos2=temp; else if(no = 2) /添加代碼實現(xiàn)交換:position與playPos1數(shù)值互換 temp=position; position=playerPos1; playerPos1=temp; break; case 2: /轟炸 if(no=1&player
14、Pos26) /no為1并且玩家2位置小于6 /添加代碼實現(xiàn):計算玩家2當前位置 playerPos2=0; /實現(xiàn)計算玩家2當前位置 else /添加代碼實現(xiàn):計算玩家2當前位置 playerPos2=playerPos2-6; if(no=2&playerPos16) /no為2并且玩家1位置小于6 /添加代碼實現(xiàn): 計算玩家1當前位置 playerPos1=0; else /添加代碼實現(xiàn):計算玩家1當前位置 playerPos1=playerPos1-6; break; break; case 2: /踩到地雷 /添加代碼實現(xiàn):踩到地雷退6步 if(no=1&playerPos26)pl
15、ayerPos1=position=playerPos1-6; else if(no=2&playerPos26)playerPos2=position=playerPos1-6; break; case 3: /下一次暫停一次 /添加代碼實現(xiàn):設置下次暫停擲骰子 if(no=1)goAndStop0=off; else if(no=2)goAndStop1=off; break; case 4: /時空隧道 /添加代碼實現(xiàn):進入時空隧道,加走10步 position=position+10;if(no=1)else if(no=2) break; /返回此次擲骰子后玩家的位置坐標 if(position 99) return 99; else retur
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 江蘇財經(jīng)職業(yè)技術(shù)學院《打印創(chuàng)新設計》2023-2024學年第二學期期末試卷
- 天津醫(yī)科大學臨床醫(yī)學院《電視節(jié)目播音主持實訓》2023-2024學年第二學期期末試卷
- 邵陽職業(yè)技術(shù)學院《結(jié)構(gòu)設計軟件應用》2023-2024學年第二學期期末試卷
- 長春職業(yè)技術(shù)學院《三維動畫MAYA》2023-2024學年第二學期期末試卷
- 內(nèi)江師范學院《SAS與統(tǒng)計分析》2023-2024學年第二學期期末試卷
- 2025年重慶市建筑安全員考試題庫附答案
- 長春師范大學《公共管理與公共政策實務》2023-2024學年第二學期期末試卷
- 西安航空學院《老年認知癥的篩查與干預》2023-2024學年第二學期期末試卷
- 南京科技職業(yè)學院《會展設計實務》2023-2024學年第二學期期末試卷
- 襄陽職業(yè)技術(shù)學院《現(xiàn)代環(huán)境分析技術(shù)與應用》2023-2024學年第二學期期末試卷
- 2025新人教版英語七年級下單詞默寫表(小學部分)
- 2025年春新外研版(三起)英語三年級下冊課件 Unit6第1課時Startup
- 2025江蘇蘇州高新區(qū)獅山商務創(chuàng)新區(qū)下屬國企業(yè)招聘9人高頻重點提升(共500題)附帶答案詳解
- 平拋運動的經(jīng)典例題
- 錄井作業(yè)現(xiàn)場風險評估及控制措施
- 2025年度商會工作計劃
- 社區(qū)管理與服務專業(yè)實習總結(jié)范文
- 施工現(xiàn)場5S管理規(guī)范
- 【MOOC】中級財務會計-西南交通大學 中國大學慕課MOOC答案
- 延續(xù)護理服務課件
- 2024年濰坊工程職業(yè)學院單招職業(yè)適應性測試題庫
評論
0/150
提交評論