diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-28 10:25:26 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-28 10:25:26 -0500 |
commit | 79daad81a4c613383d6bb05d9b47a02889bf23ab (patch) | |
tree | 1d11fc5c2a0fec43f5c57d897b2cca3f721a6598 | |
parent | 0ca04799aa1fecbde5da7d9f32dae566b9a9788e (diff) | |
download | tanetane-79daad81a4c613383d6bb05d9b47a02889bf23ab.tar.gz tanetane-79daad81a4c613383d6bb05d9b47a02889bf23ab.tar.bz2 tanetane-79daad81a4c613383d6bb05d9b47a02889bf23ab.zip |
Pathfinding should be more biased toward straight lines now
-rw-r--r-- | src/behaviour_system.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/behaviour_system.cpp b/src/behaviour_system.cpp index 3637b3e..4a194f0 100644 --- a/src/behaviour_system.cpp +++ b/src/behaviour_system.cpp | |||
@@ -156,8 +156,10 @@ void BehaviourSystem::createPath(int spriteId) { | |||
156 | Direction::up, | 156 | Direction::up, |
157 | Direction::right }; | 157 | Direction::right }; |
158 | 158 | ||
159 | const std::vector<Direction>* directionList = sprite.cardinalDirectionsOnly ? &cardinalDirections : &allDirections; | 159 | std::vector<Direction> directionList = sprite.cardinalDirectionsOnly ? cardinalDirections : allDirections; |
160 | for (Direction dir : *directionList) { | 160 | directionList.push_back(nodeInfo.dirFromPreviousPoint); |
161 | |||
162 | for (Direction dir : directionList) { | ||
161 | vec2i newPos = searchNode.point + unitVecInDirection(dir) * sprite.movementSpeed; | 163 | vec2i newPos = searchNode.point + unitVecInDirection(dir) * sprite.movementSpeed; |
162 | 164 | ||
163 | if (newPos.x() < 0 || newPos.y() < 0 || newPos.x() >= mapBounds.w() || newPos.y() >= mapBounds.h()) { | 165 | if (newPos.x() < 0 || newPos.y() < 0 || newPos.x() >= mapBounds.w() || newPos.y() >= mapBounds.h()) { |