void Puzzle::slidePiece(int x1, int y1, int x2, int y2) { int count; PointList slidePoints; slidePoints.resize(320); x1 += _pieceInfo[_puzzlePiece].offX; y1 += _pieceInfo[_puzzlePiece].offY; count = pathLine(slidePoints, 0, Point(x1, y1), Point(x2 + _pieceInfo[_puzzlePiece].offX, y2 + _pieceInfo[_puzzlePiece].offY)); if (count > 1) { int factor = count / 4; _sliding = true; if (!factor) factor++; for (int i = 1; i < count; i += factor) { _slidePointX = slidePoints[i].x; _slidePointY = slidePoints[i].y; _vm->_render->drawScene(); _vm->_system->delayMillis(10); } _sliding = false; } _pieceInfo[_puzzlePiece].curX = x2; _pieceInfo[_puzzlePiece].curY = y2; }
void Actor::nodeToPath() { uint i; Point point1, point2; for (i = 0; i < _pathList.size(); i++) { _pathList[i].x = _pathList[i].y = PATH_NODE_EMPTY; } _pathListIndex = 1; _pathList[0] = _pathNodeList[0].point; _pathNodeList[0].link = 0; for (i = 0; i < _pathNodeList.size() - 1; i++) { point1 = _pathNodeList[i].point; point2 = _pathNodeList[i + 1].point; _pathListIndex += pathLine(_pathList, _pathListIndex, point1, point2); _pathNodeList[i + 1].link = _pathListIndex - 1; } _pathListIndex--; _pathNodeList.back().link = _pathListIndex; }