diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-15 12:05:18 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-15 12:05:18 -0500 |
commit | d1235174157bd498d0c148325d7c8066e3ab6ac7 (patch) | |
tree | 1f086f5c07ebbf7721d0eb14bed6c86714164dbd /src/effect_system.cpp | |
parent | ce0628c5ad96e094db12a67d4e98b445fa873ad3 (diff) | |
download | tanetane-d1235174157bd498d0c148325d7c8066e3ab6ac7.tar.gz tanetane-d1235174157bd498d0c148325d7c8066e3ab6ac7.tar.bz2 tanetane-d1235174157bd498d0c148325d7c8066e3ab6ac7.zip |
Added camera shake to lightning event
Diffstat (limited to 'src/effect_system.cpp')
-rw-r--r-- | src/effect_system.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/effect_system.cpp b/src/effect_system.cpp index 3a0afe4..74fc8f3 100644 --- a/src/effect_system.cpp +++ b/src/effect_system.cpp | |||
@@ -18,6 +18,22 @@ void EffectSystem::tick(double dt) { | |||
18 | 18 | ||
19 | mapFade_ = (mapFadeDest_ - mapFadeStart_) / mapFadeLength_ * mapFadeThus_ + mapFadeStart_; | 19 | mapFade_ = (mapFadeDest_ - mapFadeStart_) / mapFadeLength_ * mapFadeThus_ + mapFadeStart_; |
20 | } | 20 | } |
21 | |||
22 | if (cameraShaking_) { | ||
23 | cameraShakeTimer_.accumulate(dt); | ||
24 | |||
25 | while (cameraShakeTimer_.step()) { | ||
26 | cameraShakeOn_ = !cameraShakeOn_; | ||
27 | } | ||
28 | |||
29 | if (cameraShakeOn_) { | ||
30 | cameraShakeOffset_.x() = 8; | ||
31 | cameraShakeOffset_.y() = 8; | ||
32 | } else { | ||
33 | cameraShakeOffset_.x() = 0; | ||
34 | cameraShakeOffset_.y() = 0; | ||
35 | } | ||
36 | } | ||
21 | } | 37 | } |
22 | 38 | ||
23 | void EffectSystem::fadeScreen(int length, double amount) { | 39 | void EffectSystem::fadeScreen(int length, double amount) { |
@@ -33,3 +49,15 @@ void EffectSystem::fadeMap(int length, double amount) { | |||
33 | mapFadeLength_ = length; | 49 | mapFadeLength_ = length; |
34 | mapFadeThus_ = 0; | 50 | mapFadeThus_ = 0; |
35 | } | 51 | } |
52 | |||
53 | void EffectSystem::shakeCamera(int period) { | ||
54 | cameraShaking_ = true; | ||
55 | cameraShakeOffset_ = { 0, 0 }; | ||
56 | cameraShakeOn_ = false; | ||
57 | cameraShakeTimer_ = Timer(period); | ||
58 | } | ||
59 | |||
60 | void EffectSystem::stopShakingCamera() { | ||
61 | cameraShaking_ = false; | ||
62 | cameraShakeOffset_ = { 0, 0 }; | ||
63 | } | ||