From 5c934bd482e5d230141fc2fdb7552214baa1d674 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 21 Mar 2022 13:21:00 -0400 Subject: finishing reading the story clears out all signs and a sound effect plays --- src/game.cpp | 27 ++++++++++++++++++++++----- src/game.h | 2 ++ 2 files changed, 24 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index d63c208..edc1605 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -353,7 +353,7 @@ void Game::recalculateRender() { map.at(x,y).dirtyRender = false; if (map.tile(x,y) == Tile::Floor && (!map.at(x,y).lit || !map.at(x,y).wasLit)) { - int renderDesc = 0; + /*int renderDesc = 0; if (isTileSetOrNotLit(map, x-1, y-1)) renderDesc |= (1 << 7); if (isTileSetOrNotLit(map, x , y-1)) renderDesc |= (1 << 6); if (isTileSetOrNotLit(map, x+1, y-1)) renderDesc |= (1 << 5); @@ -361,9 +361,9 @@ void Game::recalculateRender() { if (isTileSetOrNotLit(map, x+1, y+1)) renderDesc |= (1 << 3); if (isTileSetOrNotLit(map, x , y+1)) renderDesc |= (1 << 2); if (isTileSetOrNotLit(map, x-1, y+1)) renderDesc |= (1 << 1); - if (isTileSetOrNotLit(map, x-1, y )) renderDesc |= (1 << 0); + if (isTileSetOrNotLit(map, x-1, y )) renderDesc |= (1 << 0);*/ - if (/*renderDesc == 0 && */map.at(x,y).sign) { + if (/*renderDesc == 0 && */map.at(x,y).sign && !storyDone) { map.at(x,y).renderId = TilesetIndex(24, 13); } else if (std::bernoulli_distribution(0.05)(rng)) { static const std::vector furnishings { @@ -373,7 +373,7 @@ void Game::recalculateRender() { TilesetIndex(21, 3), TilesetIndex(22, 3)}; - if (/*renderDesc == 0 &&*/ !(x == player_x && y == player_y) && std::bernoulli_distribution(0.005)(rng)) { + if (/*renderDesc == 0 &&*/ !storyDone && !(x == player_x && y == player_y) && std::bernoulli_distribution(0.005)(rng)) { map.at(x,y).renderId = TilesetIndex(24, 13); map.at(x,y).sign = true; } else { @@ -385,6 +385,8 @@ void Game::recalculateRender() { map.at(x,y).renderId = -1; } } else if (map.tile(x,y) == Tile::Wall) { + map.at(x,y).sign = false; + static bool initWalls = false; static std::vector wallRenders(256, TilesetIndex(21, 12)); if (!initWalls) { @@ -477,6 +479,7 @@ void Game::recalculateRender() { } } else { map.at(x,y).renderId = -1; + map.at(x,y).sign = false; } } } @@ -783,7 +786,7 @@ void Game::updatePlaying(size_t frameTime) { if (lookTile.text.empty()) { int lineToRead = nextSignIndex++; if (nextSignIndex >= signTexts.size()) { - nextSignIndex = 0; + storyDone = true; } lookTile.text = signTexts[lineToRead]; } @@ -1098,6 +1101,20 @@ void Game::update(size_t frameTime) { menu.update(frameTime, *this); } else if (sign.signDisplayState != SignInstructionState::Hidden) { sign.update(frameTime, *this); + + if (!clearedSigns && storyDone && sign.signDisplayState == SignInstructionState::FadingOut) { + for (int y = map.getTop(); y < map.getBottom(); y++) { + for (int x = map.getLeft(); x < map.getRight(); x++) { + if (map.at(x,y).sign) { + map.at(x,y).sign = false; + map.at(x,y).renderId = -1; + } + } + } + + muxer.playSound("dash"); + clearedSigns = true; + } } else { updatePlaying(frameTime); } diff --git a/src/game.h b/src/game.h index 5bdc245..ae5f157 100644 --- a/src/game.h +++ b/src/game.h @@ -125,9 +125,11 @@ public: std::vector signTexts; int nextSignIndex = 0; + bool storyDone = false; SignInstructionState signInstructionState = SignInstructionState::Hidden; Interpolation signFade; Sign sign; + bool clearedSigns = false; Menu menu; -- cgit 1.4.1