From 8713d03831226dcd559c6a1e2b1c7b0d7c660bac Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 16 Mar 2022 11:53:46 -0400 Subject: added signs (which can't be read yet) --- src/renderer.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/renderer.cpp') diff --git a/src/renderer.cpp b/src/renderer.cpp index befad8a..2be36ae 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -109,6 +109,7 @@ Renderer::Renderer() loadTextureFromFile("../res/player.png", playerSheet_); loadTextureFromFile("../res/runninbloods.png", tileset_); loadTextureFromFile("../res/lamp.png", lamp_); + loadTextureFromFile("../res/read_instruction.png", readInstruction_); loadTextureFromFile("../res/title0.png", titles_[0]); SDL_QueryTexture(titles_[0].get(), nullptr, nullptr, &titleWidths_[0], &titleHeights_[0]); @@ -171,14 +172,14 @@ void Renderer::renderGame( SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect); if (game.map.at(x,y).renderId != -1) { - tileRect.x = game.map.at(x,y).renderId % 24 * 16; - tileRect.y = game.map.at(x,y).renderId / 24 * 16; + tileRect.x = game.map.at(x,y).renderId % 25 * 16; + tileRect.y = game.map.at(x,y).renderId / 25 * 16; SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect); } } else { SDL_Rect tileRect { - game.map.at(x,y).renderId % 24 * 16, - game.map.at(x,y).renderId / 24 * 16, + game.map.at(x,y).renderId % 25 * 16, + game.map.at(x,y).renderId / 25 * 16, 16, 16}; @@ -375,6 +376,19 @@ void Renderer::renderGame( } SDL_RenderCopy(ren_.get(), canvas.get(), &zoomRect, nullptr); + + if (game.signInstructionState != SignInstructionState::Hidden) { + int instOpacity = 255; + if (game.signInstructionState == SignInstructionState::FadingIn) { + instOpacity = game.signFade.getProgress(0, 255); + } else if (game.signInstructionState == SignInstructionState::FadingOut) { + instOpacity = game.signFade.getProgress(255, 0); + } + + SDL_SetTextureAlphaMod(readInstruction_.get(), instOpacity); + SDL_RenderCopy(ren_.get(), readInstruction_.get(), nullptr, nullptr); + } + SDL_RenderPresent(ren_.get()); } -- cgit 1.4.1