diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-06 21:27:13 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-06 21:27:13 -0500 |
commit | a990e4921820fe7b27c645639fba903329dba6b8 (patch) | |
tree | a00632e6834909f9e5325629bad6d57102d67579 | |
parent | 7ff951c90b0db3cbd66b9cc2fbb9c58941c953b4 (diff) | |
download | tanetane-a990e4921820fe7b27c645639fba903329dba6b8.tar.gz tanetane-a990e4921820fe7b27c645639fba903329dba6b8.tar.bz2 tanetane-a990e4921820fe7b27c645639fba903329dba6b8.zip |
Characters added to a party now tween to their starting position instead of teleporting
-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 | ||