JAVA小游戏骑士飞行棋.doc_第1页
JAVA小游戏骑士飞行棋.doc_第2页
JAVA小游戏骑士飞行棋.doc_第3页
JAVA小游戏骑士飞行棋.doc_第4页
JAVA小游戏骑士飞行棋.doc_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

JAVA小游戏骑士飞行棋 人机对战和双人游戏地图类:package com.sibin.flyingChess;public class Map int map = new int100; / 对战地图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 ; / 时空隧道/* * 给各个关卡赋值 */public void createMap() int i = 0; / g各个数组的下标值。for (i = 0; i luckyTurn.length; i+) mapluckyTurni = 1;for (i = 0; i landMine.length; i+) maplandMinei = 2;for (i = 0; i pause.length; i+) mappausei = 3;for (i = 0; i timeTunnel.length; i+) maptimeTunneli = 4;/* * 不同关卡在地图上的显示! * param i * param index * param play1 * param play2 * return */public String gerGrap(int i, int index, int play1, int play2) String grap = ;if (play1 = index & play2 = index) grap = ; else if (play1 = index) grap = A; else if (play2 = index) grap = B; else switch (i) case 0:grap = ;break;case 1:grap = ;break;case 2:grap = ;break;case 3:grap = ;break;case 4:grap = ;break;return grap;/* * 显示奇数行 * param start * param end * param play1 * param play2 */public void showLine1(int start, int end, int play1, int play2) for(int i = start; i = start ; i-)System.out.print(gerGrap(mapi,i,play1,play2);/显示右竖行public void showRLine(int start, int end, int play1, int play2)for(int i = start ; i 0 ; j -)System.out.print( );System.out.print(gerGrap(mapi,i,play1,play2);System.out.println();/显示左竖行public void showLLine(int start, int end, int play1, int play2)for(int i = start ; i = 99) return 99;Scanner input = new Scanner(System.in);switch (map.mapposition) case 0:if (no = 1 & play2 = position) play2 = 0;System.out.println(哈哈哈踩到了,你回去吧);if (no = 2 & play1 = position) play1 = 0;System.out.println(哈哈哈踩到了,你回去吧);break;case 1:System.out.println(=);System.out.println(欢迎进入幸运轮盘);System.out.println(请选择一种运气:1、交换位置 2、轰炸对方);System.out.println(=);int temp;int choice = input.nextInt();if (choice = 1) if(no=1)temp=position;position=play2;play2=temp;else if(no=2)temp=position;position=play1;play1=temp;else if(choice=2)if(no = 1 & play2 6)play2 = 0;else play2=play2-6;if(no=2&play16)play1=0;else play1=play1-6;break;case 2:position = position - 6;System.out.println(踩到地雷了,气死我了!);break;case 3:goOrStopno - 1 = off;System.out.println(要停战一局了!);break;case 4:position = position + 10;System.out.println(进入时空隧道真爽!);break;if (position 99) return 99;return position;/* * 操作游戏玩法 * param model 对战模式:1、双人对战 2、人机对战! */public void play(int model) System.out.println(nnnn);System.out.print(nn*n);System.out.print( Game Start n);System.out.print(nn*n);System.out.println(_ + playRole0 + 的士兵:);System.out.println(_ + playRole1 + 的士兵:B);System.out.println(n图例: + 暂停 幸运轮盘 地雷 时空隧道 普通n);map.showMap(play1, play2);/ 游戏开始int step; / 存储骰子数目while (play1 99 & play2 play2)System.out.println(n恭喜 + playRole0 + 将军! 您获胜了!);else System.out.println(n恭喜 + playRole1 + 将军! 您获胜了!);/开始游戏!public void start() init();System.out.println();System.out.println(/ 骑 士 飞 行 棋 /); System.out.println();/System.out.println(n两 人 对 战);Scanner input = new Scanner(System.in);System.out.println(请选择对战模式:1、双人游戏 2、人机对战);int choice=input.nextInt();System.out.println(n请选择角色: 1. 戴高乐 2. 艾森豪威尔 3. 麦克阿瑟 4. 巴顿); System.out.print(请玩家1选择角色: ); int role1 = input.nextInt(); int role2;int model; /传递对战模式参数!/选择是人机对战还是双人游戏!if(choice=1)model=1;doSystem.out.print(请玩家2选择角色: );role2=input.nextInt();while(role2=role1); /不允许角色重复else model=2;role2=0; /人机对战传递参数为0即电脑! setRole(1, r

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论