




已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
好几天没更新了,是因为给大家写这个小游戏去了,好久没写了,逻辑上出了问题,调试了好久终于出来了,我自己测试了下没什么大问题,不过应该还是会有BUG,希望大家下载后找到BUG了给我说下,呵呵,谢谢!代码:如下地图类Map():package com.yx.dao;/* * 地图类 * author Administrator * */public class Map / 定义地图的大小int map = new int100;int dilei = 5,16,56,72,80,85; / 定义地雷的位置int luck = 15,50,88; / 定义幸运大罗盘的位置int pulse = 9,25,35,48,65,85,92,95; / 定义暂停的位置int time = 20,39,47,68,81,90; / 定义时空隧道public int index = 0; / 定义起始位置public int playerA = 0; / 玩家A的位置public int playerB = 0; / 玩家B的位置/* * 找到定义地雷、幸运大罗盘等的位置,然后给他第一个数字来代替,为后面的判断做准备 */public void initialMap()/ 循环找出所有的地雷,并把它暂时标记为1for(int i = 0; i 100; i+) mapi = 0;for(int i =0; i dilei.length; i+) mapdileii = 1;for(int i = 0; i luck.length; i+) maplucki = 2;for(int i = 0; i pulse.length; i+) mappulsei = 3;for(int i = 0; i 99) mapplayerA = 99;if(playerB 99) mapplayerB = 99;/ 以下是判断玩家A和玩家B是不是在同一个位置上if(playerA != playerB) mapplayerA = 5;mapplayerB = 6;else mapplayerA = 7;/ 指定地雷、幸运星等在地图上的团public void printMap() switch(mapindex) case 0:System.out.print(:);break;case 1:System.out.print();break;case 2: System.out.print();break;case 3:System.out.print();break;case 4:System.out.print();break;case 5:System.out.print(A);break;case 6:System.out.print(B);break;case 7:System.out.print();break;/ 以下为地图的制作方法/* * 现实第一行横排地图 */public void showMap1() for(index = 0; index 30; index+) printMap();/* * 现实右边一列的地图 */public void showMapRight() for(index = 30; index = 35; index-) printMap();/* * 显示左边列的地图 */public void showMapLeft() for(index = 65; index 70; index+) System.out.println();printMap();/* * 最后一行的地图 */public void showMap3() for(index = 70; index = 99) map.showMap();System.out.println(n+person1 + 获得胜利!);judge();break; else game1 = true;/ 玩家可以重新移动if (game2) System.out.println(person2+ 扔筛子产生一个随机数开始:);input.next();int number = (int) (Math.random() * 6 + 1);map.playerB += number;checkGameB();System.out.println();if (map.playerB = 99) map.showMap();System.out.println(n+person2 + 获得胜利!);judge();break; else game2 = true;/ 玩家可以重新移动map.showMap(); while (true);public void checkGameA() for (int i = 0; i map.dilei.length; i+) if (map.playerA = map.dileii) System.out.println(哎,真衰,踩到地雷了!);int number = (int) (Math.random() * 6 + 1);/ 减去的是一个随机数map.playerA -= number;return;for (int i = 0; i map.luck.length; i+) if (map.playerA = map.lucki) System.out.println(嘿嘿,遇上幸转盘了,我真幸运!);System.out.println(1.交换位置 2.轰炸);System.out.println(您选择的是:);int num = input.nextInt();switch (num) case 1:int temp = map.playerB;map.playerB = map.playerA;map.playerA = temp;break;case 2:map.playerA -= 10;break;return;for (int i = 0; i map.pulse.length; i+) if (map.playerA = map.pulsei) System.out.println(唉,得休息一会了!);game1 = false;return;for (int i = 0; i map.time.length; i+) if (map.playerA = map.timei) System.out.println(哈哈,时空隧道!);map.playerA += 10;return;public void checkGameB() for (int i = 0; i map.dilei.length; i+) if (map.playerB = map.dileii) System.out.println(哎,真衰,踩到地雷了!);int number = (int) (Math.random() * 6 + 1);map.playerB -= number;/ 减去一个随机数return;for (int i = 0; i map.luck.length; i+) if (map.playerB = map.lucki) System.out.println(嘿嘿,遇上幸转盘了,我真幸运!);System.out.println(1.交换位置 2.轰炸);System.out.println(您选择的是:);int num = input.nextInt();switch (num) case 1:int temp = map.playerB;map.playerB = map.playerA;map.playerA = temp;break;case 2:map.playerA -= 10;break;return;for (int i = 0; i map.pulse.length; i+) if (map.playerB = map.pulsei) System.out.println(唉,得休息一会了!);game2 = false;return;for (int i = 0; i map.time.length; i+) if (map.playerB = map.timei) System.out.println(哈哈,时空隧道!);map.playerA += 10;return;public void judge() System.out.println(*n);System.out.println( Game Over n);System.out.println(*n);测试类,游戏入口类Star():package com.yx.test;import com.yx.dao.Game;/impor
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 煤矸石综合利用可行性研究报告
- 城市公共卫生设施建设项目招投标风险控制分析报告
- 中级银行从业资格之中级银行业法律法规与综合能力能力检测含答案详解(研优卷)
- 重庆巫山县2025年二季度事业单位选调笔试模拟试题及参考答案详解一套
- 2025年城市垃圾分类与废旧塑料资源化利用技术发展报告
- 纳米胶原蛋白再生-洞察及研究
- 自考专业(护理)试题预测试卷附参考答案详解【综合题】
- 重难点解析鲁教版(五四制)8年级数学下册测试卷(A卷)附答案详解
- 中医助理医师测试卷往年题考附答案详解
- 电竞公司赛事调度管理规章
- 热电厂巡检工培训课件
- (正式版)DB15∕T 385-2020 《行业用水定额》
- 2025年农业面源污染治理农业面源污染治理技术手册报告
- 中国黄金知识培训课件
- 人教PEP版(一起)一年级上册英语全册教案
- 光伏施工基本知识培训课件
- 2025贵州毕节市赫章县招聘事业单位工作人员123人笔试备考题库及参考答案详解
- GB 21256-2025粗钢生产主要工序单位产品能源消耗限额
- 2025AI办公发展现状软件市场竞争格局及未来发展前景分析报告
- 北京员工待岗管理办法
- 停工缓建项目管理办法
评论
0/150
提交评论