本文整理汇总了C++中Star::isSelected方法的典型用法代码示例。如果您正苦于以下问题:C++ Star::isSelected方法的具体用法?C++ Star::isSelected怎么用?C++ Star::isSelected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Star
的用法示例。
在下文中一共展示了Star::isSelected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: genSelectedList
//消除检查
void StarMatrix::genSelectedList(Star* s){
selectedList.clear();
deque<Star*> travelList;
travelList.push_back(s);
deque<Star*>::iterator it;
int color = s->getColor();
for(it= travelList.begin();it != travelList.end();){
Star* star = *it;
Star* linkStar = nullptr;
int index_i = star->getIndexI();
int index_j = star->getIndexJ();
//上
if(index_i-1 >= 0 && (linkStar = stars[index_i-1][index_j]) ){
if(!linkStar->isSelected()){
if(star->getColor()==5&&linkStar->getColor()==color){
travelList.push_back(stars[index_i-1][index_j]);
}else if((linkStar->getColor() == star->getColor()||linkStar->getColor()==5)){
travelList.push_back(stars[index_i-1][index_j]);
}
}
}
//下
if(index_i+1 < ROW_NUM && (linkStar = stars[index_i+1][index_j]) ){
if(!linkStar->isSelected()){
if(star->getColor()==5&&linkStar->getColor()==color){
travelList.push_back(stars[index_i+1][index_j]);
}else if((linkStar->getColor() == star->getColor()||linkStar->getColor()==5)){
travelList.push_back(stars[index_i+1][index_j]);
}
}
}
//左
if(index_j-1 >= 0 && (linkStar = stars[index_i][index_j-1]) ){
if(!linkStar->isSelected()){
if(star->getColor()==5&&linkStar->getColor()==color){
travelList.push_back(stars[index_i][index_j-1]);
}else if((linkStar->getColor() == star->getColor()||linkStar->getColor()==5)){
travelList.push_back(stars[index_i][index_j-1]);
}
}
}
//右
if(index_j+1 < COL_NUM && (linkStar = stars[index_i][index_j+1]) ){
if(!linkStar->isSelected()){
if(star->getColor()==5&&linkStar->getColor()==color){
travelList.push_back(stars[index_i][index_j+1]);
}else if((linkStar->getColor() == star->getColor()||linkStar->getColor()==5)){
travelList.push_back(stars[index_i][index_j+1]);
}
}
}
if(!star->isSelected()){
star->setSelected(true);
selectedList.push_back(star);
}
travelList.pop_front();
it = travelList.begin();
}
}
示例2: genBombList
//产生炸弹的消除队列
void StarMatrix::genBombList(Star* s){
selectedList.clear();
selectedList.push_back(s);
Star* linkStar = nullptr;
int index_i = s->getIndexI();
int index_j = s->getIndexJ();
//上
if(index_i-1 >= 0 && (linkStar = stars[index_i-1][index_j]) ){
if(!linkStar->isSelected())
selectedList.push_back(stars[index_i-1][index_j]);
}
//左上
if(index_i-1 >= 0 && index_j-1 >= 0&& (linkStar = stars[index_i-1][index_j-1]) ){
if(!linkStar->isSelected())
selectedList.push_back(stars[index_i-1][index_j-1]);
}
//右上
if(index_i-1 >= 0 && index_j+1 <= COL_NUM && (linkStar = stars[index_i-1][index_j+1]) ){
if(!linkStar->isSelected())
selectedList.push_back(stars[index_i-1][index_j+1]);
}
//下
if(index_i+1 < ROW_NUM && (linkStar = stars[index_i+1][index_j]) ){
if(!linkStar->isSelected())
selectedList.push_back(stars[index_i+1][index_j]);
}
//左下
if(index_i+1 < ROW_NUM && index_j-1 >= 0 && (linkStar = stars[index_i+1][index_j-1]) ){
if(!linkStar->isSelected())
selectedList.push_back(stars[index_i+1][index_j-1]);
}
//右下
if(index_i+1 < ROW_NUM && index_j+1 <= COL_NUM && (linkStar = stars[index_i+1][index_j+1]) ){
if(!linkStar->isSelected())
selectedList.push_back(stars[index_i+1][index_j+1]);
}
//左
if(index_j-1 >= 0 && (linkStar = stars[index_i][index_j-1]) ){
if(!linkStar->isSelected())
selectedList.push_back(stars[index_i][index_j-1]);
}
//右
if(index_j+1 < COL_NUM && (linkStar = stars[index_i][index_j+1]) ){
if(!linkStar->isSelected())
selectedList.push_back(stars[index_i][index_j+1]);
}
}