summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-28 10:25:26 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-28 10:25:26 -0500
commit79daad81a4c613383d6bb05d9b47a02889bf23ab (patch)
tree1d11fc5c2a0fec43f5c57d897b2cca3f721a6598 /src
parent0ca04799aa1fecbde5da7d9f32dae566b9a9788e (diff)
downloadtanetane-79daad81a4c613383d6bb05d9b47a02889bf23ab.tar.gz
tanetane-79daad81a4c613383d6bb05d9b47a02889bf23ab.tar.bz2
tanetane-79daad81a4c613383d6bb05d9b47a02889bf23ab.zip
Pathfinding should be more biased toward straight lines now
Diffstat (limited to 'src')
-rw-r--r--src/behaviour_system.cpp6
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()) {