summary refs log tree commit diff stats
path: root/src/party.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/party.cpp')
-rw-r--r--src/party.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/party.cpp b/src/party.cpp new file mode 100644 index 0000000..559aacb --- /dev/null +++ b/src/party.cpp
@@ -0,0 +1,42 @@
1#include "party.h"
2#include "consts.h"
3
4void Party::addMember(int spriteId) {
5 PartyMember newMember;
6 newMember.spriteId = spriteId;
7
8 members_.push_back(std::move(newMember));
9}
10
11void Party::move(Game& game, const Input& keystate) {
12 if (members_.empty()) {
13 return;
14 }
15
16 Sprite& p1 = game.getSprite(members_[0].spriteId);
17 vec2i pLoc = p1.loc();
18
19 if (keystate.up)
20 {
21 pLoc.y() -= MOVEMENT_SPEED;
22 }
23
24 if (keystate.down)
25 {
26 pLoc.y() += MOVEMENT_SPEED;
27 }
28
29 if (keystate.left)
30 {
31 pLoc.x() -= MOVEMENT_SPEED;
32 }
33
34 if (keystate.right)
35 {
36 pLoc.x() += MOVEMENT_SPEED;
37 }
38
39 if (pLoc != p1.loc()) {
40 p1.loc() = pLoc;
41 }
42} \ No newline at end of file