summary refs log tree commit diff stats
path: root/src/renderer.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-13 10:11:23 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-13 10:11:23 -0500
commit59dfd3da4d3e5d4a368a664c51c22bbdc8ff2ca4 (patch)
treea86427d740156719879baba4b0577285a5849f7a /src/renderer.cpp
parent560ac0c3f5fc561a3db490d8f4a33c3e19296083 (diff)
downloadtanetane-59dfd3da4d3e5d4a368a664c51c22bbdc8ff2ca4.tar.gz
tanetane-59dfd3da4d3e5d4a368a664c51c22bbdc8ff2ca4.tar.bz2
tanetane-59dfd3da4d3e5d4a368a664c51c22bbdc8ff2ca4.zip
Added sprite shadows
Diffstat (limited to 'src/renderer.cpp')
-rw-r--r--src/renderer.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/renderer.cpp b/src/renderer.cpp index 246b7fb..f07931b 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp
@@ -122,8 +122,14 @@ void Renderer::render(Game& game) {
122 122
123 SDL_RenderCopy(ren_.get(), renLay1_.get(), nullptr, nullptr); 123 SDL_RenderCopy(ren_.get(), renLay1_.get(), nullptr, nullptr);
124 124
125 int shadowTexId = loadImageFromFile("../res/shadow.png");
125 for (const Sprite& sprite : game.getSystem<TransformSystem>().getSpritesByY() | game.spriteView()) { 126 for (const Sprite& sprite : game.getSystem<TransformSystem>().getSpritesByY() | game.spriteView()) {
126 if (sprite.isAnimated) { 127 if (sprite.isAnimated) {
128 if (sprite.hasShadow) {
129 const SDL_Rect shadowDest { sprite.loc.x() - 8, sprite.loc.y() - 8, 16, 8 };
130 SDL_RenderCopy(ren_.get(), textures_.at(shadowTexId).get(), nullptr, &shadowDest);
131 }
132
127 const SpriteFrame& frame = sprite.frames.at(sprite.animations.at(sprite.animationId).at(sprite.animationFrame)); 133 const SpriteFrame& frame = sprite.frames.at(sprite.animations.at(sprite.animationId).at(sprite.animationFrame));
128 const SDL_Rect& src = frame.srcRect; 134 const SDL_Rect& src = frame.srcRect;
129 SDL_Rect dest { sprite.loc.x() - frame.center.x(), sprite.loc.y() - frame.center.y(), frame.size.w(), frame.size.h() }; 135 SDL_Rect dest { sprite.loc.x() - frame.center.x(), sprite.loc.y() - frame.center.y(), frame.size.w(), frame.size.h() };