1.界面效果
因为棋盘是固定的,所以放大之后不会改变,所以索性可以把界面锁死,不能放大与缩小,这样就比较好,而且不用再担心图片与界面不匹配的问题。
直接按设定的屏幕大小画上去。
1.1.简单双人对战模式测试(进入默认,也可自选)
可以判断输赢。
感觉优化了,反而又觉得没有以前的有感觉,好像还有bug,就是没有那种感觉了,去下以前的版本反而更有感觉。
人机模式是可以正常进行的。
1.2.帮助
点击帮助之后是这样的,没有太多的说明。
1.3.悔棋
悔棋功能很正常。棋盘上没有棋子就提示无棋可悔。
1.4.小功能选择
选择人机模式,先手,白棋,则我们是先手,白棋,因为电脑速度快,我没加休息时间。
我选择的是白棋后手,所以电脑先下了一颗黑棋。
1.5.总结
bug还很多吧,有时间再好好地修改修改,判断输赢的方法很多,我也在网上看了几篇文章,但不觉得有我这种好的,初始的我是写在一个函数里的。
bool Widget::isWin(int x,int y,int color){
int yt = 0;
int count = 0;
//南-北
yt = y;
count = 0;
while(yt - 1 >= 0 && this->chessBoard->getLocationColor(x,yt - 1) == color){
count++;
yt--;
}
yt = y;
while(yt + 1 <= 15 && this->chessBoard->getLocationColor(x,yt + 1) == color){
count++;
yt++;
}
if(count >= 4){
return true;
}
//东-西
int xt = x;
count = 0;
while(xt - 1 >= 0 && this->chessBoard->getLocationColor(xt - 1,y) == color){
count++;
xt--;
}
xt = x;
while(xt + 1 <= 15 && this->chessBoard->getLocationColor(xt + 1,y) == color){
count++;
xt++;
}
if(count >= 4){
return true;
}
//东南-西北
xt = x,yt = y;
count = 0;
while(xt - 1 >= 0 && yt - 1 >= 0 && this->chessBoard->getLocationColor(xt - 1,yt - 1) == color){
count++;
xt--;
yt--;
}
xt = x,yt = y;
while(xt + 1 <= 15 && yt + 1 <= 15 && this->chessBoard->getLocationColor(xt + 1,yt + 1) == color){
count++;
xt++;
yt++;
}
if(count >= 4){
return true;
}
//西南-东北
xt = x,yt = y;
count = 0;
while(xt + 1 <= 15 && yt - 1 >= 0 && this->chessBoard->getLocationColor(xt + 1,yt - 1) == color){
count++;
xt++;
yt--;
}
xt = x,yt = y;
while(xt - 1 >= 0 && yt + 1 <= 15 && this->chessBoard->getLocationColor(xt - 1,yt + 1) == color){
count++;
xt--;
yt++;
}
if(count >= 4){
return true;
}
return false;
}
就是从四个方向判断。