五子棋的判断输赢问题 高手救命啊
我是纯鼠标操作的,棋盘是30x30的, void judgewin()
{
int N,n,c,v;
for(n=0,N=-5;N<=5;N++) //水平方向判断
{
c=getpixel(savex+space*N,savey);//取得颜色值
if(c==color&&savex+space*N>lefttop&&savex+space*N<righttop)//如果颜色值相同,就进下一步继续判断
{
n++;
}
else break;
}
if(n>=5)
{
v=getpixel(savex,savey);
cleardevice();
settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
setcolor(RED);
if(v==BLACK)
outtextxy(200,200,"BLACK WIN");
else if(v==WHITE)
outtextxy(200,200,"WHITE WIN");
}
//else continue;
int q,t,w;
for(n=0,q=-5;q<=5;q++) //竖直方向判断
{
t=getpixel(savex,savey+space*N);
if(t==color&&savey+space*N>lefttop&&savey+space*N<righttop)
{
n++;
}
else break;
}
if(n>=5)
{
w=getpixel(savex,savey);
cleardevice();
settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
setcolor(RED);
if(w==BLACK)
outtextxy(200,200,"BLACK WIN");
else if(w==WHITE)
outtextxy(200,200,"WHITE WIN");
}
//else continue;
int b,d,z;
for(n=0,b=-5;b<=5;b++) //斜上方向判断
{
d=getpixel(savex+space*N,savey-space*N);
if(d==color&&savex+space*N>lefttop&&savex+space*N<righttop&&savey+space*N>lefttop&&savey+space*N<righttop)
{
n++;
}
else break;
}
if(n>=5)
{
z=getpixel(savex,savey);
cleardevice();
settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
setcolor(RED);
if(z==BLACK)
outtextxy(200,200,"BLACK WIN");
else if(z==WHITE)
outtextxy(200,200,"WHITE WIN");
}
//else continue;
int h,l,s;
for(n=0,h=-5;h<=5;h++) //斜下方向判断
{
l=getpixel(savex+space*N,savey+space*N);
if(l==color&&savex+space*N>lefttop&&savex+space*N<righttop&&savey+space*N>lefttop&&savey+space*N<righttop)
{
n++;
}
else break;
}
if(n>=5)
{
s=getpixel(savex,savey);
cleardevice();
settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
setcolor(RED);
if(s==BLACK)
outtextxy(200,200,"BLACK WIN");
else if(s==WHITE)
outtextxy(200,200,"WHITE WIN");
}
//else continue;
}
问题是每次都只输出黑色的赢,白色也显示黑色的赢,郁闷啊,高手速度解决下
问题补充:其中的LEFTTOP等等,是棋盘的左上方坐标,其余的类似,我怀疑是最后一点的坐标上的颜色值取的有问题(我是根据最后一步棋子的颜色判断谁赢的 )