本文整理汇总了C++中Stone::getY方法的典型用法代码示例。如果您正苦于以下问题:C++ Stone::getY方法的具体用法?C++ Stone::getY怎么用?C++ Stone::getY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stone
的用法示例。
在下文中一共展示了Stone::getY方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getStoneCountInSingleXY
//判断在走的X,Y轴上,moveID和killID之间有多少个棋子
int GameScene::getStoneCountInSingleXY(int moveID, int killID, int tox, int toy){
int count = 0;
Stone* moveStone = sts[moveID];
if (moveStone->getX() != tox && moveStone->getY() != toy){
return -1;
}
int m_x = moveStone->getX();
int m_y = moveStone->getY();
if (m_x == tox){
int y_min = m_y < toy ? m_y : toy;
int y_max = m_y > toy ? m_y : toy;
for (int i = y_min + 1; i < y_max; i++){
if (getStoneIDByXY(m_x, i) != -1){
count++;
}
}
}
else if (m_y == toy){
int x_min = m_x < tox ? m_x : tox;
int x_max = m_x > tox ? m_x : tox;
for (int i = x_min + 1; i < x_max; i++){
if (getStoneIDByXY(i, m_y) != -1){
count++;
}
}
}
else{
return -1;
}
return count;
}
示例2: canMoveBING
bool GameScene::canMoveBING(int moveID, int killID, int tox, int toy){
Stone* moveStone = sts[moveID];
int m_x = moveStone->getX();
int m_y = moveStone->getY();
int xoff = abs(m_x - tox);
int yoff = abs(m_y - toy);
int checkXY = xoff * 10 + yoff;
if (checkXY != 1 && checkXY != 10){
return false;
}
if (clickRed == moveStone->getisRed()){//棋盘的下半部分
if (toy < m_y){
return false;
}
if (m_y <= 4 && m_x != tox){//过河了
return false;
}
}
else{//棋盘的上半部分
if (toy > m_y){
return false;
}
if (m_y >= 5 && m_x != tox){//过河了
return false;
}
}
return true;
}
示例3: canMoveXIANG
bool GameScene::canMoveXIANG(int moveID, int killID, int tox, int toy){
Stone* moveStone = sts[moveID];
int m_x = moveStone->getX();
int m_y = moveStone->getY();
int xoff = abs(m_x - tox);
int yoff = abs(m_y - toy);
if (xoff != 2 || yoff != 2){
return false;
}
/*判断象眼位置*/
int mid_x = (m_x + tox) / 2;
int mid_y = (m_y + toy) / 2;
int mid_stone = getStoneIDByXY(mid_x, mid_y);
if (mid_stone != -1){
return false;
}
//如果是在棋盘下面,y如果超过4,就越过楚河汉界了
if (clickRed == sts[moveID]->getisRed()){
if (toy > 4){
return false;
}
}
else{
//如果是在棋盘上面,y如果小于5,就越过楚河汉界了
if (toy < 5){
return false;
}
}
return true;
}
示例4: canMoveSHI
bool GameScene::canMoveSHI(int moveID, int tox, int toy){
Stone* moveStone = sts[moveID];
int m_x = moveStone->getX();
int m_y = moveStone->getY();
int xoff = abs(m_x - tox);
int yoff = abs(m_y - toy);
if (xoff != 1 || yoff != 1){
return false;
}
/*判断将或帅是否走出9宫格*/
if (tox > 5 || tox < 3){
return false;
}
if (clickRed == sts[moveID]->getisRed()){
if (toy > 2 || toy < 0){
return false;
}
}
else{
if (toy > 9 || toy < 7){
return false;
}
}
return true;
}
示例5: canMoveJIANG
bool GameScene::canMoveJIANG(int moveID, int killID, int tox, int toy){
/*如果要杀的对面的将或帅,则直接按车的走法*/
if (killID != -1 && sts[killID]->getType() == Stone::JIANG){
return canMoveJU(moveID, killID, tox, toy);
}
/*判断是否走的一格*/
Stone* moveStone = sts[moveID];
int m_x = moveStone->getX();
int m_y = moveStone->getY();
int xoff = abs(m_x - tox);
int yoff = abs(m_y - toy);
int checkXY = xoff * 10 + yoff;
if (checkXY != 1 && checkXY != 10){
return false;
}
/*判断将或帅是否走出9宫格*/
if (tox > 5 || tox < 3){
return false;
}
if (clickRed == sts[moveID]->getisRed()){
if (toy > 2 || toy < 0){
return false;
}
}
else{
if (toy > 9 || toy < 7){
return false;
}
}
return true;
}
示例6: canMoveMA
bool GameScene::canMoveMA(int moveID, int killID, int tox, int toy){
Stone* moveStone = sts[moveID];
int m_x = moveStone->getX();
int m_y = moveStone->getY();
int xoff = abs(m_x - tox);
int yoff = abs(m_y - toy);
int checkXY = xoff * 10 + yoff;
if (checkXY != 12 && checkXY != 21){
return false;
}
if (xoff == 2 && (getStoneIDByXY((m_x + tox) / 2, m_y) != -1)){
return false;
}
else if (yoff == 2 && (getStoneIDByXY(m_x, (m_y + toy) / 2) != -1)){
return false;
}
else{}
return true;
}
示例7:
bool
GameScene::rabbitHitByStone()
{
int rabbitX = rabbit->getX();
int rabbitY = rabbit->getY();
for (StoneAnimation *s: stones) {
Stone *stone = s->getStone();
int stoneX = stone->getX();
int stoneY = stone->getY();
float stoneScale = stone->getScale();
if (pow((stoneX-rabbitX), 2.) + pow((stoneY-rabbitY), 2.) < pow(STONE_HIT_DISTANCE, 2.) && stoneScale > .5) {
stone->setHidden(true);
return true;
}
}
return false;
}