From 6cfb7817bf4786326fddeaf4f13675ce22ecec24 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 23 Mar 2022 12:11:43 -0400 Subject: changed how signs are generated the algorithm should be more generous with signs now, depending on the story progression and how many lit spots there are. reading a sign also clears all unread signs. the special sound is still only played after the story is complete. --- src/game.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 66b488c..7c82a38 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -229,7 +229,7 @@ bool Game::movePlayer(int x, int y) moveProgress.start(1000/6); dirtyLighting = true; - std::cout << player_x << "," << player_y << std::endl; + //std::cout << player_x << "," << player_y << std::endl; int chunkX, chunkY, old_chunkX, old_chunkY; toChunkPos(player_x, player_y, chunkX, chunkY); @@ -345,6 +345,7 @@ void Game::recalculateLighting() } void Game::recalculateRender() { + bool placedSignNear = false; for (int y = map.getTop(); y < map.getBottom(); y++) { for (int x = map.getLeft(); x < map.getRight(); x++) @@ -373,9 +374,22 @@ void Game::recalculateRender() { TilesetIndex(21, 3), TilesetIndex(22, 3)}; - if (/*renderDesc == 0 &&*/ !storyDone && !(x == player_x && y == player_y) && std::bernoulli_distribution(0.005)(rng)) { + double likelihood = 0.005; + bool tryNear = false; + if (nextSignIndex < (litSpots / 1000 + 1) && std::sqrt(std::pow(x-player_x, 2)+std::pow(y-player_y, 2)) < 30) { + if (placedSignNear) { + likelihood = 0.05; + } else { + likelihood = 0.1; + tryNear = true; + } + } + if (/*renderDesc == 0 &&*/ !storyDone && !(x == player_x && y == player_y) && map.at(x,y).text.empty() && std::bernoulli_distribution(likelihood)(rng)) { map.at(x,y).renderId = TilesetIndex(24, 13); map.at(x,y).sign = true; + if (tryNear) { + placedSignNear = true; + } } else { map.at(x,y).renderId = furnishings.at(std::uniform_int_distribution(0, furnishings.size()-1)(rng)); map.at(x,y).sign = false; @@ -792,6 +806,7 @@ void Game::updatePlaying(size_t frameTime) { } sign.displayMessage(lookTile.text); + clearedSigns = false; } else { performDash(); } @@ -1106,17 +1121,19 @@ void Game::update(size_t frameTime) { } else if (sign.signDisplayState != SignInstructionState::Hidden) { sign.update(frameTime, *this); - if (!clearedSigns && storyDone && sign.signDisplayState == SignInstructionState::FadingOut) { + if (!clearedSigns && 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) { + if (map.at(x,y).sign && (storyDone || map.at(x,y).text.empty())) { map.at(x,y).sign = false; map.at(x,y).renderId = -1; } } } - muxer.playSound("dash"); + if (storyDone) { + muxer.playSound("dash"); + } clearedSigns = true; } } else { -- cgit 1.4.1