summary refs log tree commit diff stats
path: root/src/character_system.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-20 13:34:04 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-20 13:34:04 -0500
commitf0eab98e417bf648261a9027bef91fe935af76cb (patch)
tree7c212cbe8bd549d5a6229c616806095596859a8f /src/character_system.cpp
parentca4935cb65325edbd45d4a3aacc921ea9ed9483b (diff)
downloadtanetane-f0eab98e417bf648261a9027bef91fe935af76cb.tar.gz
tanetane-f0eab98e417bf648261a9027bef91fe935af76cb.tar.bz2
tanetane-f0eab98e417bf648261a9027bef91fe935af76cb.zip
Added variable movement speed
Ionia now moves at half Lucas's speed, which I think is good for NPCs.
Diffstat (limited to 'src/character_system.cpp')
-rw-r--r--src/character_system.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/character_system.cpp b/src/character_system.cpp index 7d456f6..e6dddf6 100644 --- a/src/character_system.cpp +++ b/src/character_system.cpp
@@ -7,9 +7,10 @@
7#include "animation_system.h" 7#include "animation_system.h"
8#include "script_system.h" 8#include "script_system.h"
9 9
10void CharacterSystem::initSprite(int spriteId) { 10void CharacterSystem::initSprite(int spriteId, int movementSpeed) {
11 Sprite& sprite = game_.getSprite(spriteId); 11 Sprite& sprite = game_.getSprite(spriteId);
12 sprite.orientable = true; 12 sprite.orientable = true;
13 sprite.movementSpeed = movementSpeed;
13} 14}
14 15
15void CharacterSystem::addSpriteToParty(int leaderId, int followerId) { 16void CharacterSystem::addSpriteToParty(int leaderId, int followerId) {
@@ -29,8 +30,10 @@ void CharacterSystem::addSpriteToParty(int leaderId, int followerId) {
29 toFace = directionFacingPoint(targetPos - follower.loc); 30 toFace = directionFacingPoint(targetPos - follower.loc);
30 } 31 }
31 32
32 for (int i=0; i<PARTY_FRAME_DELAY; i++) { 33 int truePartyDelay = PARTY_FRAME_DELAY / leader.movementSpeed;
33 vec2i tween = ((follower.loc - targetPos) * i) / static_cast<double>(PARTY_FRAME_DELAY) + targetPos; 34
35 for (int i=0; i<truePartyDelay; i++) {
36 vec2i tween = ((follower.loc - targetPos) * i) / static_cast<double>(truePartyDelay) + targetPos;
34 follower.trail.push_front({.pos = tween, .dir = toFace}); 37 follower.trail.push_front({.pos = tween, .dir = toFace});
35 } 38 }
36 39
@@ -101,7 +104,7 @@ void CharacterSystem::tick(double dt) {
101 continue; 104 continue;
102 } 105 }
103 106
104 int speed = MOVEMENT_SPEED; 107 int speed = sprite.movementSpeed;
105 if (sprite.characterState == CharacterState::Running) { 108 if (sprite.characterState == CharacterState::Running) {
106 speed *= 2; 109 speed *= 2;
107 } 110 }