diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-26 18:54:38 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-26 18:54:38 -0500 |
commit | c1fc60c5a2a4b96b830afc29942648714944b9d7 (patch) | |
tree | 8460df9e93491b8ba138f7f1cba41572b65fc537 /src/animation_system.cpp | |
parent | af49b5366d35173702a2b3bd70ac4254b8855538 (diff) | |
download | tanetane-c1fc60c5a2a4b96b830afc29942648714944b9d7.tar.gz tanetane-c1fc60c5a2a4b96b830afc29942648714944b9d7.tar.bz2 tanetane-c1fc60c5a2a4b96b830afc29942648714944b9d7.zip |
Added sprite bobbing (for Lucas underwater)
Diffstat (limited to 'src/animation_system.cpp')
-rw-r--r-- | src/animation_system.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/animation_system.cpp b/src/animation_system.cpp index baf94a4..5892f64 100644 --- a/src/animation_system.cpp +++ b/src/animation_system.cpp | |||
@@ -134,6 +134,25 @@ void AnimationSystem::tick(double dt) { | |||
134 | } | 134 | } |
135 | } | 135 | } |
136 | } | 136 | } |
137 | |||
138 | bobbingTimer_.accumulate(dt); | ||
139 | while (bobbingTimer_.step()) { | ||
140 | for (Sprite& sprite : game_.getSprites() | game_.spriteView()) { | ||
141 | if (sprite.isAnimated && sprite.bobbing) { | ||
142 | if (sprite.bobbingDown) { | ||
143 | sprite.bobAmount--; | ||
144 | if (sprite.bobAmount == 0) { | ||
145 | sprite.bobbingDown = false; | ||
146 | } | ||
147 | } else { | ||
148 | sprite.bobAmount++; | ||
149 | if (sprite.bobAmount == 4) { | ||
150 | sprite.bobbingDown = true; | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | } | ||
137 | } | 156 | } |
138 | 157 | ||
139 | void AnimationSystem::setSpriteDirection(int spriteId, Direction dir) { | 158 | void AnimationSystem::setSpriteDirection(int spriteId, Direction dir) { |