summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2022-03-23 12:11:43 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2022-03-23 12:11:43 -0400
commit6cfb7817bf4786326fddeaf4f13675ce22ecec24 (patch)
tree3c459f87cd2ae0f2d5f3c5ceea3a98b8138bab0e /src
parentcd805338649b04cd9cff9185f0e229946fbadba7 (diff)
downloadether-6cfb7817bf4786326fddeaf4f13675ce22ecec24.tar.gz
ether-6cfb7817bf4786326fddeaf4f13675ce22ecec24.tar.bz2
ether-6cfb7817bf4786326fddeaf4f13675ce22ecec24.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp27
1 files changed, 22 insertions, 5 deletions
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)
229 moveProgress.start(1000/6); 229 moveProgress.start(1000/6);
230 dirtyLighting = true; 230 dirtyLighting = true;
231 231
232 std::cout << player_x << "," << player_y << std::endl; 232 //std::cout << player_x << "," << player_y << std::endl;
233 233
234 int chunkX, chunkY, old_chunkX, old_chunkY; 234 int chunkX, chunkY, old_chunkX, old_chunkY;
235 toChunkPos(player_x, player_y, chunkX, chunkY); 235 toChunkPos(player_x, player_y, chunkX, chunkY);
@@ -345,6 +345,7 @@ void Game::recalculateLighting()
345} 345}
346 346
347void Game::recalculateRender() { 347void Game::recalculateRender() {
348 bool placedSignNear = false;
348 for (int y = map.getTop(); y < map.getBottom(); y++) 349 for (int y = map.getTop(); y < map.getBottom(); y++)
349 { 350 {
350 for (int x = map.getLeft(); x < map.getRight(); x++) 351 for (int x = map.getLeft(); x < map.getRight(); x++)
@@ -373,9 +374,22 @@ void Game::recalculateRender() {
373 TilesetIndex(21, 3), 374 TilesetIndex(21, 3),
374 TilesetIndex(22, 3)}; 375 TilesetIndex(22, 3)};
375 376
376 if (/*renderDesc == 0 &&*/ !storyDone && !(x == player_x && y == player_y) && std::bernoulli_distribution(0.005)(rng)) { 377 double likelihood = 0.005;
378 bool tryNear = false;
379 if (nextSignIndex < (litSpots / 1000 + 1) && std::sqrt(std::pow(x-player_x, 2)+std::pow(y-player_y, 2)) < 30) {
380 if (placedSignNear) {
381 likelihood = 0.05;
382 } else {
383 likelihood = 0.1;
384 tryNear = true;
385 }
386 }
387 if (/*renderDesc == 0 &&*/ !storyDone && !(x == player_x && y == player_y) && map.at(x,y).text.empty() && std::bernoulli_distribution(likelihood)(rng)) {
377 map.at(x,y).renderId = TilesetIndex(24, 13); 388 map.at(x,y).renderId = TilesetIndex(24, 13);
378 map.at(x,y).sign = true; 389 map.at(x,y).sign = true;
390 if (tryNear) {
391 placedSignNear = true;
392 }
379 } else { 393 } else {
380 map.at(x,y).renderId = furnishings.at(std::uniform_int_distribution<int>(0, furnishings.size()-1)(rng)); 394 map.at(x,y).renderId = furnishings.at(std::uniform_int_distribution<int>(0, furnishings.size()-1)(rng));
381 map.at(x,y).sign = false; 395 map.at(x,y).sign = false;
@@ -792,6 +806,7 @@ void Game::updatePlaying(size_t frameTime) {
792 } 806 }
793 807
794 sign.displayMessage(lookTile.text); 808 sign.displayMessage(lookTile.text);
809 clearedSigns = false;
795 } else { 810 } else {
796 performDash(); 811 performDash();
797 } 812 }
@@ -1106,17 +1121,19 @@ void Game::update(size_t frameTime) {
1106 } else if (sign.signDisplayState != SignInstructionState::Hidden) { 1121 } else if (sign.signDisplayState != SignInstructionState::Hidden) {
1107 sign.update(frameTime, *this); 1122 sign.update(frameTime, *this);
1108 1123
1109 if (!clearedSigns && storyDone && sign.signDisplayState == SignInstructionState::FadingOut) { 1124 if (!clearedSigns && sign.signDisplayState == SignInstructionState::FadingOut) {
1110 for (int y = map.getTop(); y < map.getBottom(); y++) { 1125 for (int y = map.getTop(); y < map.getBottom(); y++) {
1111 for (int x = map.getLeft(); x < map.getRight(); x++) { 1126 for (int x = map.getLeft(); x < map.getRight(); x++) {
1112 if (map.at(x,y).sign) { 1127 if (map.at(x,y).sign && (storyDone || map.at(x,y).text.empty())) {
1113 map.at(x,y).sign = false; 1128 map.at(x,y).sign = false;
1114 map.at(x,y).renderId = -1; 1129 map.at(x,y).renderId = -1;
1115 } 1130 }
1116 } 1131 }
1117 } 1132 }
1118 1133
1119 muxer.playSound("dash"); 1134 if (storyDone) {
1135 muxer.playSound("dash");
1136 }
1120 clearedSigns = true; 1137 clearedSigns = true;
1121 } 1138 }
1122 } else { 1139 } else {