diff options
Diffstat (limited to 'src/party.cpp')
| -rw-r--r-- | src/party.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
| diff --git a/src/party.cpp b/src/party.cpp index 559aacb..6c003b8 100644 --- a/src/party.cpp +++ b/src/party.cpp | |||
| @@ -1,10 +1,20 @@ | |||
| 1 | #include "party.h" | 1 | #include "party.h" |
| 2 | #include "consts.h" | 2 | #include "consts.h" |
| 3 | 3 | ||
| 4 | void Party::addMember(int spriteId) { | 4 | void Party::addMember(Game& game, int spriteId) { |
| 5 | int index = members_.size(); | ||
| 6 | |||
| 5 | PartyMember newMember; | 7 | PartyMember newMember; |
| 6 | newMember.spriteId = spriteId; | 8 | newMember.spriteId = spriteId; |
| 7 | 9 | ||
| 10 | if (index > 0) { | ||
| 11 | Sprite& sprite = game.getSprite(spriteId); | ||
| 12 | |||
| 13 | for (int i = 0; i < PARTY_FRAME_DELAY * index; i++) { | ||
| 14 | newMember.nextPosition.push_back(sprite.loc()); | ||
| 15 | } | ||
| 16 | } | ||
| 17 | |||
| 8 | members_.push_back(std::move(newMember)); | 18 | members_.push_back(std::move(newMember)); |
| 9 | } | 19 | } |
| 10 | 20 | ||
| @@ -36,7 +46,14 @@ void Party::move(Game& game, const Input& keystate) { | |||
| 36 | pLoc.x() += MOVEMENT_SPEED; | 46 | pLoc.x() += MOVEMENT_SPEED; |
| 37 | } | 47 | } |
| 38 | 48 | ||
| 39 | if (pLoc != p1.loc()) { | 49 | if (keystate.up || keystate.down || keystate.left || keystate.right) { |
| 40 | p1.loc() = pLoc; | 50 | p1.loc() = pLoc; |
| 51 | |||
| 52 | for (int i = 1; i < members_.size(); i++) { | ||
| 53 | Sprite& pNext = game.getSprite(members_[i].spriteId); | ||
| 54 | members_[i].nextPosition.push_back(pLoc); | ||
| 55 | pNext.loc() = members_[i].nextPosition.front(); | ||
| 56 | members_[i].nextPosition.pop_front(); | ||
| 57 | } | ||
| 41 | } | 58 | } |
| 42 | } \ No newline at end of file | 59 | } \ No newline at end of file |
