zoukankan      html  css  js  c++  java
  • 第五篇 Scrum冲刺博客

    一、站立式会议

    1.1 会议照片

    1.2成员工作情况

    成员 昨天已完成的工作 今天计划完成的工作 工作中遇到的困难
    马文辉 完成了拼图选择和难度选择的界面 实现练习模式下游戏的正式体验 在选择完图片和难度后与练习界面之间的连接和参数传递进行了多次修改
    卢力衔 设计出了练习模式的界面 整合计时器和练习模式的代码 难以找到组件对应顶级容器
    张朝阳 对主界面做了些修改,界面内的插件可随窗口大小而变化 实现点击按钮跳转 跳转后的界面具体设计不会,交给其他队友
    张龙伟 完成了顺序计时跟倒计时 只有开始计时的按扭,因为游戏会有开始、暂停、继续、重新游戏四个按钮,所以计时器也要有与之匹配的功能,所以设计了四个监听器单击事件 每次点击后都必须删除原来的按扭,添加新的按扭,一开始没想好,所以出了些bug
    周勇铨 完成排名榜只在闯关模式显示排名榜的功能(95%) 剩余多种功能一起开发 想出一个可以方便进行排名的成绩计算方式

    二、项目燃尽图

    三、代码/文档签入记录

    3.1 代码签入

    3.2 Issue链接

    成员 Issue链接
    马文辉 练习模式模块
    卢力衔 游戏校验
    张朝阳 主界面
    张龙伟 计时模块
    周勇铨 排行榜

    3.3 CodeReview代码规范文档

    四、最新程序/模块

    4.1 程序代码

    package cn.homework.util;
    
    import java.awt.Image;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    
    import javax.imageio.ImageIO;
    
    // 图片切割类
    public class ImageCut {
    	
    	/**
    	 * 
    	 * @param source 图片源路径
    	 * @param pattern  切割成 pattern*pattern
    	 * @param savePath 切割完的碎片存储路径
    	 * @return
    	 */
    	public static boolean cutImage(BufferedImage image, int pattern, String savePath) {
    		try {
    				int imgWidth = image.getWidth();
    				int imgHeight = image.getHeight();
    				int width = (int) (imgWidth * 1.0/ pattern);
    				int height = (int)(imgHeight * 1.0 / pattern);
    				for(int i=0; i<pattern; i++) {
    					for(int j=0; j<pattern; j++) {
    						ImageIO.write(image.getSubimage(j*width, i*height, width, height), "jpg", 
    								new File(savePath + "\" + (i * pattern + j) + ".jpg"));
    					}
    				}
    				return true;
    		} catch(IOException e) {
    				e.printStackTrace();
    				return false;
    		}
    		
    	}
    }
    
    
    package cn.homework.util.panel;
    
    import java.awt.Color;
    import java.awt.GridLayout;
    import java.awt.Image;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.util.Random;
    
    import javax.imageio.ImageIO;
    import javax.swing.BorderFactory;
    import javax.swing.ImageIcon;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    
    import cn.homework.util.ImageCut;
    import cn.homework.util.button.PPButton;
    import cn.homework.util.image.ImageView;
    
    /**
     * 
     * 游戏区域 以及相应的拼图校验
     *
     */
    public class OperationPanel extends JPanel{
    	PPButton[] button; // 按钮数组
    	Image[] img; // 图片数组
    	int[] order; // 照片存放顺序
    	int nullButton; //空白按钮
    	int pattern; //拼图规模
    	int total;
    
    
    	public OperationPanel(BufferedImage image, int pattern) {
    		this.pattern = pattern;
    		this.total = pattern * pattern;
    		button = new PPButton[total];
    		img = new Image[total];
    		order = new int[total];
    		nullButton = total - 1;
    		sliceRandom(image);
    	}
    	
    	public void sliceRandom(BufferedImage image) {
    		ImageCut.cutImage(image, pattern, "slice"); //将给定的图片按照指定的模式切分到指定路径里
    		this.removeAll();
    		this.updateUI();
    		this.setLayout(new GridLayout(pattern, pattern));
    		random(order);
    		for(int i=0;i<total;i++){   
    	    	//初始化按钮
    	    	button[i]=new PPButton();
    	    	button[i].setRow(i/pattern);//初始化每一个按钮所在的行
    	    	button[i].setCol(i%pattern);//初始化每一个按钮所在的列
    		    this.add(button[i]);
    	    }
    		for(int i=0;i<total-1;i++){
    			try {
    				img[i] = ImageIO.read(new File("slice" + "\" + order[i] + ".jpg"));
    				button[i].setImage(img[i]);
    				button[i].setScaleType(ImageView.FIT_XY);
    				button[i].setBorder(BorderFactory.createLineBorder(Color.black));
    			} catch (IOException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			}
    		}
    		button[nullButton].setImage(null);
    		
    		for(int i=0;i<total;i++){   
    	    	//给每一个按钮添加监听事件
    	    	button[i].addMouseListener(new MouseAdapter(){
    				@Override
    				public void mousePressed(MouseEvent e) {
    					PPButton button=(PPButton)e.getSource();
    					remove(button);
    				}
    	    	});
    	    }
    		
    	}
    	
    	//产生随机数组,打乱图片位置
    	public void random(int a[]){
    	    while(true){
    			Random cd=new Random();
    			int i=0;
    			a[0]=cd.nextInt(total-1);
    			for(i=1;i<total-1;i++)
    			{
    				int temp=cd.nextInt(total-1);
    				for(int j=0;j<i;j++)
    				{
    					if(a[j]!=temp)
    					{
    						a[i]=temp;
    					}
    					else
    					{
    						i--;
    						break;
    					}
    				}
    			}
    			a[i]=total-1;
    			if(isOdd(a))
    				return;
    	   }
    	}
    	
    	
    	 public boolean isOdd(int a[]){
    	    	int sum=0;
    	    	for(int i=0;i<total;i++)
    	    		for(int j=i+1;j<total;j++)
    	    		{
    	    			if(a[i]>a[j])
    	    				sum++;
    	    		}
    	    	if(sum%2==0)
    	    		return true;
    	    	else
    	    		return false;
    	    	
    	 }
    	 
    	 public void remove(PPButton clicked){
    			int rowN=button[nullButton].getRow();//得到空白按钮横坐标
    			int colN=button[nullButton].getCol();//得到空白按钮纵坐标
    			int rowC=clicked.getRow();//得到点击按钮横坐标
    			int colC=clicked.getCol();//得到点击按钮纵坐标
    			if(((rowN-rowC)==1&&(colN-colC)==0)||
    			   ((rowN-rowC)==-1&&(colN-colC)==0)||
    			   ((rowN-rowC)==0&&(colN-colC)==1)||
    			   ((rowN-rowC)==0&&(colN-colC)==-1))
    			{
    				Image img= clicked.getImage();//得到点击按钮的图片
    				button[nullButton].setImage(img);//设置空白按钮的图片,即交换空白按钮与点击按钮的图片
    				clicked.setImage(null);//设置点击按钮图片为空白
    			    int click = rowC*pattern + colC;//获得点击按钮是第几个按钮
    			    order[nullButton] = order[click];//交换图片数组的顺序状态
    			    order[click] = total - 1;
    			    nullButton=click;//设置空白按钮是第几个
    			    check();
    			}
    			else
    			{
    				return;
    			}
    	}
    	 
    	//判断拼图是否完成
    	public boolean check(){
    		int i;
    		for(i=0;i<total;i++)
    			if(order[i]!=i)
    				return false;
    			
    		if(i == total)
    			return true;
    		return true;
    		
    	}
    }
    
    package cn.homework.view;
    
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JButton;
    import java.awt.BorderLayout;
    import javax.swing.JPanel;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import cn.homework.util.CountClock;
    import cn.homework.util.SwingConsole;
    import cn.homework.util.image.ImageView;
    
    import cn.homework.util.panel.OperationPanel;
    
    import java.awt.image.BufferedImage;
    /*
     * 练习模式界面
     */
    public class LIANXI_view {
    	
    	JPanel jpanelTime = new JPanel();
    	CountClock cc = new CountClock(0, jpanelTime, null, CountClock.LIANXI);
    	
    	private JFrame jf = new JFrame();
    	
    	public LIANXI_view(BufferedImage image, int pattern) {
    		init(image, pattern);
    		SwingConsole.run(jf);
    	}
    	
    	
    	public void closeThis(){
    		jf.dispose();
    	}
    	
    	
    	public void init(BufferedImage image, int pattern) {
    		
    
    		cc.init();
    		
    		JPanel top = new JPanel();
    		JPanel buttom = new JPanel();
    		JButton back = new JButton("返回");
    		back.setPreferredSize(new Dimension(100, 100));
    		back.addActionListener(new Tomenu());
    		
    		top.setLayout(new BorderLayout());
    		top.add(jpanelTime);
    		top.add(back, BorderLayout.EAST);
    		
    		jf.add(top, BorderLayout.NORTH);
    		
    		ImageView previewArea = new ImageView();
    		previewArea.setImage(image);
    		OperationPanel operateArea  = new OperationPanel(image, pattern);
    		
    		new Thread( new Runnable() {
    			@Override
    			public void run() {
    				while(true)
    				{
    					try {
    						Thread.sleep(1000);
    					} catch (InterruptedException e) {
    						// TODO Auto-generated catch block
    						e.printStackTrace();
    					}
    					if( operateArea.check() == true ) {
    						cc.setStopCountFlag(true);
    						
    						JButton ctn = new JButton("继续");
    						JButton rtn = new JButton("返回");
    						
    						ctn.addActionListener(new CtnGame());
    						rtn.addActionListener(new Tomenu());
    						
    						JButton[] bs = {ctn, rtn};
    						JOptionPane.showOptionDialog(operateArea, "拼图完成", "选择", 1,3, null, bs, bs[0]);
    						break;
    					}
    				}
    			}
    		}).start();
    		
    		buttom.setLayout(new GridLayout(1, 2));
    		buttom.add(previewArea);
    		buttom.add(operateArea);
    		
    		jf.add(buttom);
    		
    	}
    
    	class Tomenu implements ActionListener {
    
    		@Override
    		public void actionPerformed(ActionEvent e) {
    			// TODO Auto-generated method stub
    			cc.setStopCountFlag(true);
    			
    			jf.dispose();
    			
    			PINTU window = new PINTU();
    			
    			SwingConsole.run(window.PINTU);			
    		}
    	}
    	
    	class CtnGame implements ActionListener {
    	  
    		@Override
    		public void actionPerformed(ActionEvent e) {
    			jf.dispose();
    			// TODO Auto-generated method stub
    			SelectPractice s = new SelectPractice("选择当前图片");
    			SwingConsole.run(s);
    		}
    	    
    	}
    }
    

    4.2 运行截图

    五、每人每日总结

    成员 小结
    马文辉 队员某衔居然恋上玩这款游戏..
    卢力衔 找到了getTopLevelAncestor方法->外面的世界很大
    张朝阳 对跳转后的界面并没有太多的设计,能力有限,这部分交给了注册逻辑事件的队友,结合具体开发实现的操作对界面进行设计。
    张龙伟 今日的工作是为了方便与游戏模块的整合,代码大体完成了,人也感觉到轻松了
    周勇铨 时间不足,只能赶进度了
  • 相关阅读:
    Redis 常用模式思路
    MacOS Catalina 10.15 利用shell脚本启动NGINX、MySQL、PHP
    windows上 python有多版本,如何管理,如何区别?
    20180813视频笔记 深度学习基础上篇(1)之必备基础知识点 深度学习基础上篇(2)神经网络模型视频笔记:深度学习基础上篇(3)神经网络案例实战 和 深度学习基础下篇
    20180813视频笔记 深度学习基础上篇(1)之必备基础知识点 深度学习基础上篇(2)神经网络模型
    数据集
    基于深度学习的目标跟踪
    使用GitHub+Hexo建立个人网站,并绑定自己的域名(Ubuntu环境下)
    使用jemdoc制作个人主页
    《2017全球人工智能人才白皮书》发布丨解读世界顶级AI牛人的秘密——腾讯研究院
  • 原文地址:https://www.cnblogs.com/Mhuihui/p/12977080.html
Copyright © 2011-2022 走看看