java 五子棋源代码 package chess; ; ; ; ; ; ; ; ; ; ; ; ; lass Chess extendsJFrameimplementsMouseListener, Runnable { privatestaticfinallongserialVersionUID = 1L; intwidth = ().getScreenSize().width; inthight = ().getScreenSize().height; // 背景图片 BufferedImagebjImage = null; // 保存棋子坐标 intx = 0; inty = 0; // 保存之前下过的棋子坐标// 其中数据: 0: 表示这个点没有棋子 1 :表示黑子 2 :表示白子 int[][] allChess = newint[19][19]; // 标识当前是黑棋还是白旗下下一步 booleanisBlack = true; // 标识当前游戏是否可以继续 booleancanPlay = true; // 保存显示的提示信息 String message =" 黑方先行"; // 保存最多拥有多少时间(秒) intmaxTime = 0; // 做倒计时的线程类 Thread t= newThread(this); // 保存黑方与白方的剩余时间 intblackTime = 0; intwhiteTime = 0; // 保存双方剩余时间的显示信息 String blackMessage =" 无限制"; String whiteMessage =" 无限制"; ***@SuppressWarnings("deprecation") public Chess() { (" 五子棋"); (500, 500); ((width - 500) / 2, (hight - 500) / 2); (this); // (false); (true); (null); (); t// 线程挂起// 刚打开的时候刷新屏幕, 防止开始游戏时无法显示的问题 (); (); try { bjImage = (new File("C:\\Users\\cwb\\Desktop\\")); } catch (IOExceptione) { (); }} ***@Override publicvoid paint(Graphics g){ // 双缓存技术防止屏幕闪烁但不知道为什么,使用双缓存技术以后, 效果特不好,所以没用,如果使用的话,下面的 g 改为 g2 就可以了//BufferedImage(500,500,); //Graphics g=(); (bjImage, 0, 20, this); (new Font(" 黑体", , 20)); (" 游戏信息: "+ message, 120, 60); (new Font(" 宋体", 0, 14)); (" 黑方时间: "+ blackMessage, 30, 470); (" 白方时间: "+ whiteM
java五子棋源代码 来自淘豆网m.daumloan.com转载请标明出处.