本文整理汇总了C++中GImage::getX方法的典型用法代码示例。如果您正苦于以下问题:C++ GImage::getX方法的具体用法?C++ GImage::getX怎么用?C++ GImage::getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GImage
的用法示例。
在下文中一共展示了GImage::getX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeMove
bool MarbleGraphics::makeMove(const Move move){
GImage * movingMarble = marbles[move.startRow][move.startCol];
int jumpedRow = move.startRow+(move.endRow-move.startRow)/2;
int jumpedCol = move.startCol+(move.endCol-move.startCol)/2;
GImage * jumpedMarble = marbles[jumpedRow][jumpedCol];
if (movingMarble == NULL || jumpedMarble == NULL){
return false;
}
//Move empty spot from end to start of move
GOval* endSpot = spaces[move.endRow][move.endCol];
double tempX = endSpot->getX();
double tempY = endSpot->getY();
endSpot->setLocation(movingMarble->getX(), movingMarble->getY());
spaces[move.startRow][move.startCol] = endSpot;
spaces[move.endRow][move.endCol] = NULL;
spaceCoords[endSpot] = Coord(move.startRow, move.startCol);
//Move image at start location to image at end location
movingMarble->setLocation(tempX, tempY);
marbles[move.endRow][move.endCol] = movingMarble;
marbles[move.startRow][move.startCol] = NULL;
marbleCoords[movingMarble] = Coord(move.endRow, move.endCol);
//Delete marble for jumped space and create empty space there instead
marbles[jumpedRow][jumpedCol] = NULL;
marbleCoords.remove(jumpedMarble);
remove(jumpedMarble);
delete jumpedMarble;
GOval* jumpedSpace = new GOval(kMarbleDimension, kMarbleDimension);
spaces[jumpedRow][jumpedCol] = jumpedSpace;
spaceCoords[jumpedSpace] = Coord(jumpedRow, jumpedCol);
add(jumpedSpace, jumpedCol*(kMarbleDimension+kMarbleSpacingWidth)+kMarbleSpacingWidth,
jumpedRow*(kMarbleDimension+kMarbleSpacingWidth)+kMarbleSpacingWidth);
return true;
}