1.团队博客链接
2.个人负责模块:
3.关键代码截图:
1.Frame
2.Mouse
int chess_x = Math.round((float)(click_x-20)/gap);
int chess_y = Math.round((float)(click_y-20)/gap); //Math.round是四舍五入函数,这是对棋子放置范围进行四舍五入规划
if((isBlack==true&&Chess[chess_x][chess_y]=='0' && flag == false )||(flag == true &&isBlack==false&&Chess[chess_x][chess_y]=='0')){
//放置棋子成功,并且为黑棋,下一步颜色转换为白棋
Chess[chess_x][chess_y] = '2';
isBlack = false;//换为白子
flag = false;
}
if((isBlack==false&&Chess[chess_x][chess_y]=='0'&& flag == false ) || ( flag == true &&isBlack==true &&Chess[chess_x][chess_y]=='0')){
//放置棋子成功,并且为白棋,下一步颜色转换为黑棋
Chess[chess_x][chess_y] = '1';
isBlack = true;//换为黑子
flag = false;
}
repaint(); //重新绘制,记录之前放置的棋子,类似刷新棋盘
if(isWin(chess_x,chess_y,isBlack)){ //根据isBlack弹出JOptionPane窗口告知输赢
if(isBlack){
JOptionPane.showMessageDialog(null,"白子赢了");
//当此时未放置棋子颜色为黑子,但白棋已满足isWin函数,故弹出窗口显示白棋赢
}else{
JOptionPane.showMessageDialog(null,"黑子赢了");
//当此时未放置棋子颜色为白子,但黑棋已满足isWin函数,故弹出窗口显示黑棋赢
}
3.jar--->exe
4.个人码云截图