bool CCLLKDlg::IsLink(int x1, int y1, int x2, int y2) { StartPoint.x=m_iSeekX+x1*FRONTWIDTH-FRONTWIDTH/2; StartPoint.y=m_iSeekY+y1*FRONTHEIGHT-FRONTHEIGHT/2; EndPoint.x=m_iSeekX+x2*FRONTWIDTH-FRONTWIDTH/2; EndPoint.y=m_iSeekY+y2*FRONTHEIGHT-FRONTHEIGHT/2; if (x1==x2) { if (X1_Link_X2(x1,y1,y2)) { LinkKind=LINK_0_POINT; return true; } } else if (y1==y2) { if (Y1_Link_Y2(x1,x2,y1)) { LinkKind=LINK_0_POINT; return true; } } if(OneCornerLink(x1,y1,x2,y2)) { LinkKind=LINK_1_POINT; return true; } else if (TwoCornerLink(x1,y1,x2,y2)) { LinkKind=LINK_2_POINT; return true; } return false; }
bool CGameLogic::IsLink(int anMap[MAX_ROW][MAX_COL],Vertex v1, Vertex v2) { PushVertex(v1); //Link is a straight line of horizontal if(v1.row == v2.row) { if(LinkInRow(anMap,v1,v2)) return true; if(TwoCornerLink(anMap,v1,v2)) return true; } //link in a straight line of vertical else if(v1.col == v2.col) { if(LinkInCol(anMap,v1,v2)) return true; if(TwoCornerLink(anMap,v1,v2)) return true; } else if(OneCornerLink(anMap,v1,v2)) { PushVertex(v2); return true; } else if(TwoCornerLink(anMap,v1,v2)) { return true; } PopVertex(); return false; }