示例#1
0
bool MapManager::matchVertical(int gridId1, int gridId2) {
    //两点在垂直方向上,能否通过2次折线连接
    Grid* g1 = this->getGrid(gridId1);
    Grid* g2 = this->getGrid(gridId2);

    if (g1 == NULL || g2 == NULL) {
        return false;
    }
    vector<int> g1List = getVerticalEmpty(g1->id);
    vector<int> g2List = getVerticalEmpty(g2->id);
    int g1Len = g1List.size();
    int g2Len = g2List.size();
    for (int i = 0; i < g1Len; i++) {
        Grid* g1Temp = this->getGrid(g1List[i]);
        for (int j = 0; j < g2Len; j++) {
            Grid* g2Temp = this->getGrid(g2List[j]);
            if (g1Temp->row == g2Temp->row) {
                if (isRowEmpty(g1Temp->row, g1Temp->col, g2Temp->col)) {
                    m_path.push_back(gridId1);
                    m_path.push_back(g1Temp->id);
                    m_path.push_back(g2Temp->id);
                    m_path.push_back(gridId2);
                    return true;
                }
            }
        }
    }

    return false;
}
示例#2
0
int
BoundsCalculator::getBottom()
{
	const uchar *row = getRow(fLeft, fBottom);

	int bottom;
	for (bottom = fBottom; bottom >= fTop; bottom --) {
		if (!isRowEmpty((const rgb_color*)row)) {
			break;
		}
		row -= fBPR;
	}
	
	return bottom;
}
示例#3
0
int 
BoundsCalculator::getTop()
{	
	const uchar* row = getRow(fLeft, fTop);

	int top;
	for (top = fTop; top <= fBottom; top ++) {
		if (!isRowEmpty((const rgb_color*)row)) {
			break;
		}
		row += fBPR;
	}
	
	return top;
}
示例#4
0
bool MapManager::matchLine(int gridId1, int gridId2) {
    //判断一条连线上是否能消除
    m_path.clear();

    Grid* g1 = getGrid(gridId1);
    Grid* g2 = getGrid(gridId2);

    if (g1 == NULL || g2 == NULL) {
        return false;
    }

    if (g1->row == g2->row) {
        return isRowEmpty(g1->row, g1->col, g2->col);
    }

    if (g1->col == g2->col) {
        return isColEmpty(g1->col, g1->row, g2->row);
    }

    return false;
}