summary refs log tree commit diff stats
path: root/src/animation_system.cpp
diff options
context:
space:
mode:
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) {