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/renderer.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/renderer.cpp')
| -rw-r--r-- | src/renderer.cpp | 3 | 
1 files changed, 3 insertions, 0 deletions
| diff --git a/src/renderer.cpp b/src/renderer.cpp index 1196e50..3007378 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp | |||
| @@ -115,6 +115,9 @@ void Renderer::renderSprite(const Sprite& sprite) { | |||
| 115 | const SpriteFrame& frame = sprite.frames.at(sprite.animations.at(sprite.animationId).frameIndices.at(sprite.animationFrame)); | 115 | const SpriteFrame& frame = sprite.frames.at(sprite.animations.at(sprite.animationId).frameIndices.at(sprite.animationFrame)); | 
| 116 | const SDL_Rect& src = frame.srcRect; | 116 | const SDL_Rect& src = frame.srcRect; | 
| 117 | SDL_Rect dest { sprite.loc.x() - frame.center.x(), sprite.loc.y() - frame.center.y(), frame.size.w(), frame.size.h() }; | 117 | SDL_Rect dest { sprite.loc.x() - frame.center.x(), sprite.loc.y() - frame.center.y(), frame.size.w(), frame.size.h() }; | 
| 118 | if (sprite.bobbing) { | ||
| 119 | dest.y -= sprite.bobAmount; | ||
| 120 | } | ||
| 118 | SDL_RenderCopy(ren_.get(), textures_.at(loadImageFromFile(sprite.spritesheet)).get(), &src, &dest); | 121 | SDL_RenderCopy(ren_.get(), textures_.at(loadImageFromFile(sprite.spritesheet)).get(), &src, &dest); | 
| 119 | } | 122 | } | 
| 120 | } | 123 | } | 
