diff --git a/source/World.cpp b/source/World.cpp index f862ec7..8d3e58b 100755 --- a/source/World.cpp +++ b/source/World.cpp @@ -156,12 +156,12 @@ World::astarArea(Area* start, Area* end) const { * * @param start Position to start the path from. * @param end Position to move to. - * @param diameter Diameter of the moving object. + * @param radius Radius of the moving object. * @return Path from end to start (path from start to end in reverse order). */ std::vector World::getPath(const sf::Vector2f& start, const sf::Vector2f& end, - float diameter) const { + float radius) const { std::vector portals = astarArea(getArea(start), getArea(end)); std::vector path; @@ -176,11 +176,11 @@ World::getPath(const sf::Vector2f& start, const sf::Vector2f& end, if (percentage < 0 || percentage > 1.0f) { if (thor::squaredLength(p->start - path.back()) < thor::squaredLength(p->end - path.back())) { - thor::setLength(startToEnd, 0.5f * diameter); + thor::setLength(startToEnd, radius); point = p->start + startToEnd; } else { - thor::setLength(startToEnd, 0.5f * diameter); + thor::setLength(startToEnd, radius); point = p->end - startToEnd; } } @@ -189,7 +189,7 @@ World::getPath(const sf::Vector2f& start, const sf::Vector2f& end, } // Take two points on a line orthogonal to the portal. - thor::setLength(startToEnd, diameter / 2.0f); + thor::setLength(startToEnd, radius); startToEnd = thor::perpendicularVector(startToEnd); path.push_back(point + startToEnd); path.push_back(point - startToEnd); diff --git a/source/World.h b/source/World.h index 6a90232..db5ecce 100755 --- a/source/World.h +++ b/source/World.h @@ -32,7 +32,7 @@ public: void step(int elapsed); void generateAreas(); std::vector getPath(const sf::Vector2f& start, - const sf::Vector2f& end, float diameter) const; + const sf::Vector2f& end, float radius) const; // Private types. private: diff --git a/source/abstract/Character.cpp b/source/abstract/Character.cpp index 29b6a6e..381c477 100644 --- a/source/abstract/Character.cpp +++ b/source/abstract/Character.cpp @@ -127,7 +127,7 @@ Character::releaseTrigger() { */ bool Character::setDestination(const sf::Vector2f& destination) { - mPath = mWorld.getPath(getPosition(), destination, 2 * getRadius()); + mPath = mWorld.getPath(getPosition(), destination, getRadius()); if (!mPath.empty()) { setSpeed(mPath.back() - getPosition(), mMovementSpeed); }