summary refs log tree commit diff stats
path: root/src/animation_system.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-26 18:54:38 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-26 18:54:38 -0500
commitc1fc60c5a2a4b96b830afc29942648714944b9d7 (patch)
tree8460df9e93491b8ba138f7f1cba41572b65fc537 /src/animation_system.cpp
parentaf49b5366d35173702a2b3bd70ac4254b8855538 (diff)
downloadtanetane-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.cpp19
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
139void AnimationSystem::setSpriteDirection(int spriteId, Direction dir) { 158void AnimationSystem::setSpriteDirection(int spriteId, Direction dir) {