JAVA面向对象编程课程设计——伊蕾娜扫雷小游戏

目录

一、团队成员

二、项目GIT地址

三、项目GIT提交记录截图

四、主要功能流程图与项目功能架构图

功能流程图

功能架构图

五、面向对象设计类图

功能类图:

图片文件:(图片未全部截取)

六、项目运行截图

游戏界面

难度选择

世界观

开始剧情

踩雷剧情

​编辑​

胜利

​编辑​

失败

七、项目关键代码

鼠标监听

打开方块

八、代码静态扫描

代码扫描结果及改正后结果

​编辑

改正步骤

九、尚待改进


一、团队成员

成员姓名

任务分配

个人博客

郑宜群(组长)

Mine与Panel的编程,Git远程仓库的实现与管理,剧情文本的编写,程序架构的构思

http://t.csdnimg.cn/aXscT

郑昊翔Logic的编程,团队博客编写,GIF图片的获取与绘制,将程序打包成jar文件
张哲议Frame的编程,使用静态代码扫描工具进行代码扫描并改正,相关图片的查找

二、项目GIT地址

郑宜群/ElainaMineWeeper (gitee.com)

三、项目GIT提交记录截图

四、主要功能流程图与项目功能架构图

功能流程图


功能架构图

五、面向对象设计类图

功能类图:


图片文件:(图片未全部截取)

六、项目运行截图

游戏界面


难度选择


世界观


开始剧情


踩雷剧情


胜利


失败

七、项目关键代码

鼠标监听

public void mouseReleased(MouseEvent e) //鼠标释放监听
	{
		//游戏结束,退出
		if(this.isGameOver) {return;}
		
		//游戏未开始,开始游戏,不退出
	    if(this.isStart == false)
		{
			this.isStart = true;
			this.timer.start();
		}
		
        Object obj = e.getSource();
        
        //鼠标左键点击
        if(e.getButton() == MouseEvent.BUTTON1)
        {
            if(obj instanceof JButton)
            {
            	JButton jbMine = (JButton)obj;
            	String location[] = jbMine.getName().split("_");
            	int row = Integer.parseInt(location[0]);
            	int column = Integer.parseInt(location[1]);
            	this.logic.openCell(row,column);	//打开该格子
            	if(this.falts==0&&this.storyFalts[0]==0)
            	{
            		this.storyFalts[0]=1;
            		JOptionPane.showMessageDialog(null, this.story[0], "一切的开始还是结束?", JOptionPane.INFORMATION_MESSAGE,this.storyBegin);	
            	}
            	else if(this.falts==1&&this.storyFalts[1]==0) {
            		this.storyFalts[1]=1;
            		JOptionPane.showMessageDialog(null, this.story[1], "遭遇敌人", JOptionPane.INFORMATION_MESSAGE,this.storyProcess);
            	}
            	else if(this.falts==5) {
            		JOptionPane.showMessageDialog(null, this.story[2], "旅行结束", JOptionPane.INFORMATION_MESSAGE,this.storyTrouble);
            	}
            	
            }
        }
else if(e.getButton() == MouseEvent.BUTTON3)    //鼠标右键点击
        {
            if(obj instanceof JButton)
            {
	        	JButton jbMine = (JButton)obj;
	        	String location[] = jbMine.getName().split("_");
	        	int row = Integer.parseInt(location[0]);
	        	int column = Integer.parseInt(location[1]);
	        	if(this.mapMine[row][column].get("flag") == 0)		//处于未打开状态插红旗
	        	{
	        		this.mapMine[row][column].put("flag",2);
	        		this.buttonMine[row][column].setIcon(this.imageIconFlag);
	        		this.buttonMine[row][column].setPressedIcon(this.imageIconFlag);
	        		//更改地雷提示数字
	        		this.mineTip--;
	        		this.logic.setNumberTip(this.mineTip,0);
	        	}
	        	else if(this.mapMine[row][column].get("flag") == 2)	//处于插红旗状态变问号
	        	{
	        		this.mapMine[row][column].put("flag",3);
	        		this.buttonMine[row][column].setIcon(this.imageIconQuestion);
	        		this.buttonMine[row][column].setPressedIcon(this.imageIconQuestion);
	        		//更改地雷提示数字
	        		this.mineTip++;
	        		this.logic.setNumberTip(this.mineTip,0);
	        	}
	        	else if(this.mapMine[row][column].get("flag") == 3)	//处于问号状态变未打开
	        	{
	        		this.mapMine[row][column].put("flag",0);
	        		this.buttonMine[row][column].setIcon(this.imageIconSquare);
	        		
	        	}
            }
        }
		
	}

打开方块

	public void openCell(int row,int column)
	{
    	
		//如果打开或者标红旗则跳过
		if(this.panel.mapMine[row][column].get("flag") == 1 || this.panel.mapMine[row][column].get("flag") == 2){return;}
		
		if(this.panel.mapMine[row][column].get("number") <= -1)			//踩到地雷了
		{
			this.panel.falts++;
			this.panel.mineTip--;
			this.setNumberTip(this.panel.mineTip,0);
			this.panel.mapMine[row][column].put("flag",1);
			if(this.panel.falts==5)
			{
				this.showMine();//显示所以雷
			}
			
    	    this.panel.buttonMine[row][column].setIcon(this.panel.imageBlackNumber[-this.panel.mapMine[row][column].get("number")]);
    		this.panel.buttonMine[row][column].setPressedIcon(this.panel.imageBlackNumber[-this.panel.mapMine[row][column].get("number")]);
			
    		
    		if(this.panel.falts==5)
    		{
    		
    			this.panel.isGameOver = true;
    			this.panel.isStart = false;
    			return;
    		}
    		
		}
		
		else	//踩到数字处
		{
			this.panel.mapMine[row][column].put("flag",1);
			this.panel.buttonMine[row][column].setIcon(this.panel.imageIconNumber[this.panel.mapMine[row][column].get("number")]);
    		this.panel.buttonMine[row][column].setPressedIcon(this.panel.imageIconNumber[this.panel.mapMine[row][column].get("number")]);
			
		}
		
		//判断游戏是否结束
		if(this.gameOver())
		{
			this.panel.isGameOver = true;
    		this.panel.isStart = false;
			this.panel.timer.stop();
		}
		
	}

八、代码静态扫描

代码扫描结果及改正后结果

未改结果

改正成果

改正步骤

第一种错误:缺少覆盖标志@Override


第二种错误:变量名不符合小驼峰式命名风格


第三种错误:命名以下划线开始

九、尚待改进

不足:游戏难度跨度过大;剧情方面还有较大提升空间;游戏结束时,计时未停止;窗口大小无法调节。

改进方向:对游戏难度进行平衡处理;丰富剧情,提高剧情与游戏的关联性;处理计时未停止问题;添加窗口大小调节按钮。

  • 21
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值