diff options
-rw-r--r-- | src/behaviour_system.cpp | 15 | ||||
-rw-r--r-- | src/behaviour_system.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/behaviour_system.cpp b/src/behaviour_system.cpp index a05912c..b68cd6d 100644 --- a/src/behaviour_system.cpp +++ b/src/behaviour_system.cpp | |||
@@ -40,6 +40,21 @@ void BehaviourSystem::tick(double dt) { | |||
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
43 | overcorrectionTimer_.accumulate(dt); | ||
44 | while (overcorrectionTimer_.step()) { | ||
45 | for (int spriteId : game_.getSprites()) { | ||
46 | Sprite& sprite = game_.getSprite(spriteId); | ||
47 | if (!sprite.paused && | ||
48 | sprite.behaviourType == BehaviourType::Path && | ||
49 | !sprite.path.empty() && | ||
50 | sprite.loc != sprite.path.front().endpoint) { | ||
51 | if (directionFacingPoint(sprite.path.front().endpoint - sprite.loc) != sprite.path.front().dir) { | ||
52 | game_.getSystem<TransformSystem>().moveSprite(spriteId, sprite.path.front().endpoint); | ||
53 | } | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | |||
43 | for (int spriteId : game_.getSprites()) { | 58 | for (int spriteId : game_.getSprites()) { |
44 | Sprite& sprite = game_.getSprite(spriteId); | 59 | Sprite& sprite = game_.getSprite(spriteId); |
45 | if (!sprite.paused && sprite.behaviourType == BehaviourType::Path) { | 60 | if (!sprite.paused && sprite.behaviourType == BehaviourType::Path) { |
diff --git a/src/behaviour_system.h b/src/behaviour_system.h index 526a09b..1ddce4a 100644 --- a/src/behaviour_system.h +++ b/src/behaviour_system.h | |||
@@ -31,6 +31,7 @@ private: | |||
31 | 31 | ||
32 | Game& game_; | 32 | Game& game_; |
33 | Timer timer_ { 500 }; | 33 | Timer timer_ { 500 }; |
34 | Timer overcorrectionTimer_ { 1000/60 }; | ||
34 | }; | 35 | }; |
35 | 36 | ||
36 | #endif /* end of include guard: BEHAVIOUR_SYSTEM_H_FC908ABE */ | 37 | #endif /* end of include guard: BEHAVIOUR_SYSTEM_H_FC908ABE */ |