diff options
-rw-r--r-- | src/character_system.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/character_system.cpp b/src/character_system.cpp index 3df4f9a..fcd69dd 100644 --- a/src/character_system.cpp +++ b/src/character_system.cpp | |||
@@ -15,8 +15,19 @@ void CharacterSystem::addSpriteToParty(int leaderId, int followerId) { | |||
15 | Sprite& leader = game_.getSprite(leaderId); | 15 | Sprite& leader = game_.getSprite(leaderId); |
16 | Sprite& follower = game_.getSprite(followerId); | 16 | Sprite& follower = game_.getSprite(followerId); |
17 | 17 | ||
18 | int index = leader.followers.size() + 1; | 18 | vec2i targetPos = leader.loc; |
19 | follower.trail = std::deque<Movement>(PARTY_FRAME_DELAY * index, {.pos = follower.loc, .dir = follower.dir}); | 19 | |
20 | if (!leader.followers.empty()) { | ||
21 | Sprite& backFollower = game_.getSprite(leader.followers.back()); | ||
22 | follower.trail = backFollower.trail; | ||
23 | targetPos = backFollower.loc; | ||
24 | } | ||
25 | |||
26 | Direction toFace = directionFacingPoint(targetPos - follower.loc); | ||
27 | for (int i=0; i<PARTY_FRAME_DELAY; i++) { | ||
28 | vec2i tween = ((follower.loc - targetPos) * i) / static_cast<double>(PARTY_FRAME_DELAY) + targetPos; | ||
29 | follower.trail.push_front({.pos = tween, .dir = toFace}); | ||
30 | } | ||
20 | 31 | ||
21 | leader.followers.push_back(followerId); | 32 | leader.followers.push_back(followerId); |
22 | 33 | ||