急求骑士飞行棋的代码
\u9a91\u58eb\u98de\u884c\u68cb\u7684\u4ee3\u7801\u8c01\u77e5\u9053\u5440\uff1f\u9a91\u58eb\u98de\u884c\u68cb\u6e38\u620f\u7c7bjava\u4ee3\u7801java\u4ee3\u7801package s1java.xmal1;import java.util.*;public class Game { Scanner input=new Scanner(System.in); Map map=new Map(); int playerPos1=0; int playerPos2=0; int pos; int shu; int no; int i=0; String[]goAndStop={"on","on"}; String[]playerName=new String[2]; public void setRole(){ boolean t69=false; int role=1; int role1; System.out.println("\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b"); System.out.println("// //"); System.out.println("// //"); System.out.println("// \u9a91 \u58eb \u98de \u884c \u68cb //"); System.out.println("// //"); System.out.println("// //"); System.out.println("\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\u203b\n\n\n"); System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~\u4e24 \u4eba \u5bf9 \u6218~~~~~~~~~~~~~~~~~~~~~~~~~~~"); do{ t69=false; System.out.println("\n\t\t\t\t\u8bf7\u9009\u62e9\u89d2\u8272\uff1a\n1\uff1a\u6839\u53f7\u4e09(\u50b2\u89c6\u7fa4\u82f1)\t2:\u535c\u8d5e\u658c(\u5fe0\u4e49\u4e4b\u58eb) \t3\uff1a\u7f57 \u5f6d(\u552f\u5a1f\u72ec\u7231)\n4\uff1a\u5218 \u6021(\u6d4b\u4f60\u5355\u8bcd)\t" + "5\uff1a\u674e\u795d\u8363(\u5973\u4e2d\u8c6a\u6770)\t6\uff1a\u960e \u9f99(\u9f99\u5927\u516c\u516c)\n7\uff1a\u90dd\u4e49\u68ee(\u597d\u597d\u5b66\u4e60)\t8\uff1a\u6234\u6770\u797a(\u7b56\u4eba\u4e13\u5bb6)\t9: \u6768 \u6b22(\u516d\u4e5d\u7a00\u82b1)"); System.out.print("\u8bf7\u9009\u62e9\u73a9\u5bb61\u7684\u89d2\u8272\uff1a\t"); role=input.nextInt(); role1=role; switch(role){ case 1: playerName[0]="\u6839\u53f7\u4e09(\u50b2\u89c6\u7fa4\u82f1)";break; case 2: playerName[0]="\u535c\u8d5e\u658c(\u5fe0\u4e49\u4e4b\u58eb)";break; case 3: playerName[0]="\u7f57 \u5f6d(\u552f\u5a1f\u72ec\u7231)";break; case 4: playerName[0]="\u5218 \u6021(\u6d4b\u4f60\u5355\u8bcd)";break; case 5: playerName[0]="\u674e\u795d\u8363(\u5973\u4e2d\u8c6a\u6770)";break; case 6: playerName[0]="\u960e \u9f99(\u9f99\u5927\u516c\u516c)";break; case 7: playerName[0]="\u90dd\u4e49\u68ee(\u597d\u597d\u5b66\u4e60)";break; case 8: playerName[0]="\u6234\u6770\u797a(\u7b56\u4eba\u4e13\u5bb6)";break; case 9: playerName[0]="\u6768 \u6b22(\u516d\u4e5d\u7a00\u82b1)";break; default: System.out.print("\n\u4e3aT69\u4e89\u5149\uff01\u4eba\u4eba\u6709\u8d23\uff01\u8bf7\u91cd\u65b0\u9009\u62e9\uff01"); t69=true; } }while(t69); do{ System.out.print("\u8bf7\u9009\u62e9\u73a9\u5bb62\u7684\u89d2\u8272\uff1a\t"); role=input.nextInt(); if(role==role1){ System.out.println("\u73a9\u5bb62\u4e0d\u80fd\u548c\u73a9\u5bb61\u7684\u89d2\u8272\u9009\u4e00\u6837\uff01"); } switch(role){ case 1: playerName[1]="\u6839\u53f7\u4e09(\u50b2\u89c6\u7fa4\u82f1)";break; case 2: playerName[1]="\u535c\u8d5e\u658c(\u5fe0\u4e49\u4e4b\u58eb)";break; case 3: playerName[1]="\u7f57 \u5f6d(\u552f\u5a1f\u72ec\u7231)";break; case 4: playerName[1]="\u5218 \u6021(\u6d4b\u4f60\u5355\u8bcd)";break; case 5: playerName[1]="\u674e\u795d\u8363(\u5973\u4e2d\u8c6a\u6770)";break; case 6: playerName[1]="\u960e \u9f99(\u9f99\u5927\u516c\u516c)";break; case 7: playerName[1]="\u90dd\u4e49\u68ee(\u597d\u597d\u5b66\u4e60)";break; case 8: playerName[1]="\u6234\u6770\u797a(\u7b56\u4eba\u4e13\u5bb6)";break; case 9: playerName[1]="\u6768 \u6b22(\u516d\u4e5d\u7a00\u82b1)";break; default: System.out.print("\u4e3aT69\u4e89\u5149\uff01\u4eba\u4eba\u6709\u8d23\uff01\u8bf7\u91cd\u65b0\u9009\u62e9\uff01"); } }while(role==role1||role>9||role=99){ pos=99; } int []luckyTurn={9,25,40,55,71,88}; int []diLei={6,19,27,38,50,66,75,83,91}; int []zanTing={11,48,63,82}; int []shiKongSuiDao={10,23,36,52,69,80}; int []map=new int [100]; for(i=0;i
google\u4e00\u4e0b\uff0c\u5c31\u80fd\u627e\u5230\u554a\uff0c\u3002\u3002\u3002
画MAP类:package s1java.xmal1;
public class Map {
int[] map=new int[100]; //0:普通
int[] luckyTurn={6,23,40,55,69,83}; //1:幸运轮盘
int[] landMine={5,13,17,33,38,50,64,80,94};//2:地雷
int[] pause={9,27,60,93}; //3:暂停
int[] timeTunnel={20,25,45,63,72,88,90}; //4:时空隧道
//给map[]写入各种符号
public void createMap(){
for(int i=0;i<luckyTurn.length;i++){
map[luckyTurn[i]]=1;
}
for(int i=0;i<landMine.length;i++){
map[landMine[i]]=2;
}
for(int i=0;i<pause.length;i++){
map[pause[i]]=3;
}
for(int i=0;i<timeTunnel.length;i++){
map[timeTunnel[i]]=4;
}
}
public void showMap(int playerPos1,int playerPos2){
showLine1(0,31,playerPos1,playerPos2);
showRLine(31,35,playerPos1,playerPos2);
showLine2(35,66,playerPos1,playerPos2);
showLLine(66,69,playerPos1,playerPos2);
showLine1(69,100,playerPos1,playerPos2);
}
public void showLine1(int start,int end,int playerPos1,int playerPos2){
for(int i=start;i<end;i++ ){
System.out.print(getGraph(map[i],i,playerPos1,playerPos2));
}
System.out.println();
}
public void showRLine(int start,int end,int playerPos1,int playerPos2){
for(int i=start;i<end;i++){
for(int j=0;j<73;j++){
System.out.print(" ");
}
System.out.println(getGraph(map[i],i,playerPos1,playerPos2));
}
}
public void showLine2(int start,int end,int playerPos1,int playerPos2){
for(int i=end-1;i>=start;i--){
System.out.print(getGraph(map[i],i,playerPos1,playerPos2));
}
System.out.println();
}
public void showLLine(int start,int end,int playerPos1,int playerPos2){
for(int i=start;i<end;i++){
System.out.println(getGraph(map[i],i,playerPos1,playerPos2));
}
}
public String getGraph(int i,int index,int playerPos1,int playerPos2){
String graph=" ";
if(index==playerPos1&&index==playerPos2){
graph="@@";
}else if(index==playerPos1){
graph="A";
}else if(index==playerPos2){
graph="B";
}else{
switch(i){
case 1:
graph="¤";
break;
case 2:
graph="★";
break;
case 3:
graph="■";
break;
case 4:
graph="〓";
break;
default:graph="⊙";
break;
}
}
return graph;
}
}
Game类:
package s1java.xmal1;
import java.util.Scanner;
public class Game {
Scanner input = new Scanner(System.in);
Map map;
int playerPos1;
int playerPos2;
String[] goAndStop=new String[2];
String[] playerName=new String[2];
public void init(){
map=new Map();
map.createMap();
map.showMap(0, 0);
goAndStop[0]="on";
goAndStop[1]="on";
}
public void setRole(int no,int role){
switch(role){
case 1:playerName[no-1]="比尔";break;
case 2:playerName[no-1]="奥巴马";break;
case 3:playerName[no-1]="普京";break;
case 4:playerName[no-1]="布朗";break;
}
}
public int throwShifter(int no){
int step=0;
System.out.println(playerName[no-1]+"按任意字母键回车:");
String answer=input.next();
step=(int)(Math.random()*10%6)+1;
return step;
}
public int getCurPos(int no,int position,int step){
position=position+step;
if(position>99){
return 99;
}
switch(map.map[position]){
case 0://普通格
if(no==1&&playerPos2==position){//玩家1与玩家2相遇
playerPos2=0;
System.out.println(":-D 哈哈哈...踩到了!");
}else if(no==2&&playerPos1==position){
playerPos1=0;
System.out.println(":-D 哈哈哈...踩到了!");
}
break;
case 1://幸运轮盘
System.out.println("\n◆◇◆◇◆◇欢迎进入幸运轮盘◆◇◆◇◆◇");
System.out.println("请选择一种运气:");
System.out.println("1.交换位置2.轰炸对手");
int choice=input.nextInt();
int temp;
switch(choice){
case 1: //交换位置
if(no==1){
temp=position;
position=playerPos2;
playerPos2=temp;
}else if(no==2){
temp=position;
position=playerPos1;
playerPos1=temp;
}
break;
case 2: //轰炸对手
if(no==1){
if(playerPos2<6){
playerPos2=0;
}else{
playerPos2-=6;
}
}else if(no==2){
if(playerPos1<6){
playerPos1=0;
}else{
playerPos1-=6;
} }
break;
}
break;
case 2://地雷
position-=6;
System.out.println("踩到地雷,气死了。");
break;
case 3://暂停
goAndStop[no-1]="off";
System.out.println("~~>_<~~ 要停战一局了。");
break;
case 4://时空隧道
position+=10;
System.out.println("|-P 进入时空隧道真爽!");
break;
}
if(position<0){
return 0;
}else if(position>99){
return 99;
}else{
return position;
}
}
public void judge(){
if(playerPos1>playerPos2){
System.out.println("玩家1"+playerName[0]+"最先到达终点,获得胜利。恭喜!恭喜!");
}else{
System.out.println("玩家2"+playerName[1]+"最先到达终点,获得胜利。恭喜!恭喜!");
}
}
public void play(){
System.out.println("\n\n\n\n");
System.out.println("\n※※※※※※※※※※※※※※※※※※※※※※※※※\n");
System.out.println(" Game Start \n");
System.out.println("※※※※※※※※※※※※※※※※※※※※※※※※※\n\n");
System.out.println("^_^"+playerName[0]+"的士兵: A");
System.out.println("^_^"+playerName[1]+"的士兵: B\n");
System.out.println("\n图例:"+"■暂停 ¤幸运轮盘 ★地雷 〓时空隧道 ⊙ 普通\n");
map.showMap(playerPos1, playerPos2);
int step;
while(playerPos1<99&&playerPos2<99){
if(goAndStop[0].equals("on")){
step= throwShifter(1);
System.out.println("\n-----------------------");
System.out.println("骰子数"+step);
playerPos1=getCurPos(1,playerPos1,step);
System.out.println("你"+playerName[0]+"当前的位置:"+playerPos1);
System.out.println("对手"+playerName[1]+"当前的位置:"+playerPos2);
System.out.println("\n-----------------------");
map.showMap(playerPos1, playerPos2);
if(playerPos1==99){
break;
}
}else{
System.out.println("\n"+playerName[0]+"停掷一次。\n");
goAndStop[0]="on";
}
System.out.println("\n\n\n\n");
if(goAndStop[1].equals("on")){
step= throwShifter(2);
System.out.println("\n-------------------------------");
System.out.println("骰子数"+step);
playerPos2=getCurPos(2,playerPos2,step);
System.out.println("你"+playerName[1]+"当前的位置:"+playerPos2);
System.out.println("对手"+playerName[0]+"当前的位置:"+playerPos1);
System.out.println("\n-------------------------------");
map.showMap(playerPos1, playerPos2);
if(playerPos2==99){
break;
}
}else{
System.out.println("\n"+playerName[1]+"停掷一次。\n");
goAndStop[1]="on";
}
System.out.println("\n\n\n\n");
}
System.out.println("\n\n\n\n");
System.out.println("\n************************************************\n");
System.out.println(" Game Over \n");
System.out.println("************************************************\n\n");
judge();
}
public void start(){
init();
System.out.println("\n※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※");
System.out.println("// //");
System.out.println("// //");
System.out.println("// 骑士飞行棋 //");
System.out.println("// //");
System.out.println("// //");
System.out.println("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※");
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~两人对战~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println("请选择角色:1.比尔2.奥巴马3.普京4.布朗");
System.out.println("请玩家1选择角色:");
int role1=input.nextInt();
int role2;
do{
System.out.println("请玩家2选择角色:");
role2=input.nextInt();
}while(role2==role1);
setRole(1,role1);
setRole(2,role2);
play();
}
}
主方法类:
package s1java.xmal1;
public class StartGame {
public static void main(String[] args) {
Game game=new Game();
game.start();
}
}
绛旓細楠戝+椋炶妫娓告垙绫籮ava浠g爜java浠g爜package s1java.xmal1;import java.util.*;public class Game { Scanner input=new Scanner(System.in); Map map=new Map(); int playerPos1=0; int playerPos2=0; int pos; int shu; int no; int i=0; String[]goAndStop={"on","on"}; String[]...
绛旓細package s1java.xmal1;public class Map { int[] map=new int[100]; //0:鏅 int[] luckyTurn={6,23,40,55,69,83}; //1锛氬垢杩愯疆鐩 int[] landMine={5,13,17,33,38,50,64,80,94};//2锛氬湴闆 int[] pause={9,27,60,93}; //3锛氭殏鍋 int[] timeTunnel={20,25,45,...
绛旓細opinion1涓轰汉鏈哄鎴锛宱pinion3涓巓pinion4瀵规墜锛屾寜閽1涓哄鎵1锛屾寜閽2涓哄鎵2 Private Sub Command1_Click()Static a As Integer If a = 0 Then a = a - 1 Randomize Text1.Text = Int((Rnd * 6) + 1)a = Val(Text1.Text) + a Label1(a).Alignment = 2 Label1(a).Caption = "A...
绛旓細//娣诲姞浠g爜瀹炵幇鍦ㄥ鎴樺湴鍥句笂璁剧疆鍦伴浄 for(i = 0; i < landMine.length; i++) { map[landMine[i]] = 2; } //娣诲姞浠g爜瀹炵幇鍦ㄥ鎴樺湴鍥句笂璁剧疆鏆傚仠 for(i = 0; i< pause.length; i++) { map[pause[i]] = 3; } //娣诲姞浠g爜瀹炵幇鍦ㄥ鎴樺湴鍥句笂璁剧疆鏃剁┖闅ч亾 for(i = 0; i < timeTunnel.length; ...
绛旓細娓告垙瑙勫垯璺熶紶缁熺殑椋炶妫涓妯′竴鏍凤紝鏀寔2锝4浜烘垨鑰呬汉鏈哄鎴樸傝鑹插拰鍦烘櫙棰犺浜嗕紶缁熸牱寮忥紝鎰熻闈炲父鐨勭簿鑷淬傛父鎴忔鐩樺緢灏忥紝閬撳叿涓板瘜锛岀數鑴戠殑鏀诲嚮寰堜富鍔紝鎵浠ュ鎴樼浉褰撴縺鐑堛傘 鑻辨枃鍚嶇О锛欴on't get angry娓告垙绫诲瀷锛氭鐗屾父鎴忚繍琛岀幆澧冿細Win9x/Me/NT/2000/XP/2003/vista/win7娓告垙澶у皬锛5.80MB娓告垙璇█锛氳嫳鏂/...
绛旓細浼犵粺椋炶妫嬭鍒欓噷,鐜╁瑕佸垰濂借蛋鍒扮粓鐐瑰鎵嶈兘绠椻滃埌杈锯,濡傛灉鐜╁鎵斿嚭鐨勯瀛愮偣鏁版棤娉曞垰濂借蛋鍒扮粓鐐瑰,澶氬嚭鏉ョ殑鐐规暟,妫嬪瓙灏嗗線鍥炶蛋銆 鍏充簬缁堢偣,杩樻湁浠ヤ笅鍑犵鏀硅繘瑙勫垯: 濡傞瀛愮偣鏁板杩囦簬鍒扮粓鐐圭殑鏍兼暟,涔熶笉闇瑕佸悗閫,鍙互鐩存帴鑳滃埄杩斿洖銆 濡傛灉妫嬪瓙涓嶈兘鍒氬ソ鎶佃揪缁堢偣,鍒欎抚澶辨湰娆$Щ鍔ㄦ満浼氭垨浜ょ敱鍏朵粬妫嬪瓙浠h(濡楠戝+椋炶妫)銆
绛旓細褰撴病鏈夋椿鍔ㄧ殑鍏垫椂锛屾瘡瀹跺彲浠ヨ繛缁墧3娆★紝鐩村埌鎵斿嚭6鐐归噴鏀惧嚭涓涓叺銆備箣鍚庢瘡杞彧鑳芥墧涓娆★紝妫鍏靛墠杩涚殑鏍兼暟鐢辨墧鍑虹殑鐐规暟鍐冲畾锛屾墧鍑犵偣灏辫蛋鍑犳銆傛棤璁烘槸鍓嶈繘鎴栬呭悗閫锛屽綋妫嬪叺鏈鍚庤惤鑴氱殑鍦版柟韪╁埌瀵规柟妫嬪叺鏃讹紝灏辨妸瀵规柟妫嬪叺杞板洖鑰佸锛屽綋韪╁埌鍦伴浄灏卞悗閫6鏍硷紝褰撹俯鍒扳滐紵鈥濇椂锛屽氨杩涘叆骞歌繍杞洏锛岄噷闈㈡湁8绉...
绛旓細鐜╁椋炴満椋炶嚦缁堢偣鏃讹紝杩欐灦椋炴満灏卞畬鎴愪换鍔★紝鎶㈠厛灏嗘墍鏈夐鏈洪鑷崇粓鐐圭殑鐜╁闃熶紞锛堣嫢鑷敱浜哄氨鏄帺瀹朵釜浜猴級鑳滃埄銆傚叧浜庣粓鐐癸紝杩樻湁浠ヤ笅鍑犵鏀硅繘瑙勫垯锛氬楠板瓙鐐规暟澶氳繃浜庡埌缁堢偣鐨勬牸鏁帮紝涔熶笉闇瑕佸悗閫锛屽彲浠ョ洿鎺ヨ儨鍒╄繑鍥炪傚鏋滄瀛愪笉鑳藉垰濂芥姷杈剧粓鐐癸紝鍒欎抚澶辨湰娆$Щ鍔ㄦ満浼氭垨浜ょ敱鍏朵粬妫嬪瓙浠h锛堝楠戝+椋炶妫锛夈傚鏋滅帺瀹...
绛旓細濡傛灉妫嬪瓙涓嶈兘鍒氬ソ鎶佃揪缁堢偣锛屽垯涓уけ鏈绉诲姩鏈轰細鎴栦氦鐢卞叾浠栨瀛愪唬琛岋紙濡楠戝+椋炶妫锛夈傚鏋滅帺瀹舵墧鍑虹殑楠板瓙鐐规暟鏃犳硶鍒氬ソ璧板埌缁堢偣澶勶紝澶氬嚭鏉ョ殑鐐规暟锛屾瀛愬皢鎸夌収椤烘椂閽堢殑鏂瑰悜鍦ㄧ粓鐐瑰尯鍩熷厹鍦堬紝鐩村埌鍒拌揪宸辨柟缁堢偣锛涘湪缁堢偣鍖哄煙鍙互杩瓙鍜屾挒瀛愶紱鍦ㄥ繁鏂圭粓鐐瑰鎾炲瓙鍚庯紝蹇呴』鑷冲皯鍐嶅厹涓鍦堟墠鍙互鍒拌揪缁堢偣锛堟瘮濡傚湪宸辨柟...
绛旓細椋炶妫閲屾湁涓涓瀛愶紝浣犲彧瑕佽浆鍔ㄩ瀛愶紝楠板瓙鍋滀笅鏉ョ殑鏃跺欐闈㈡槸鍑狅紝浣犲氨璧板嚑姝ャ傚垰寮濮嬫椂鍙湁鎶曞埌鍏紝浣犵殑椋炴満鎵嶈兘璧烽锛屽苟涓旀姇鍒板叚浣犺繕鏈夋満浼氬啀鎶曚竴娆°傜壒鍒鏄庣殑鏄紝鍒扮粓鐐规椂璧扮殑姝ユ暟瑕佹濂藉埌杈炬墠绠楄儨鍒╋紝涓嶇劧瑕佽繑鍥炴潵璧般傞琛屾杩欑杞湀寮忕殑璺▼璁捐鏉ヨ嚜浜庣┖鎴樹腑鐨勨滄媺寮椾集闆峰渾鍦堚濄傛硶鍥戒汉鎷夊紬浼浄瀵...