From 47c584d8a583bab3a71333e9993b72cf481bca2f Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 3 Jun 2018 11:54:16 -0400 Subject: decreased dust light radius this makes it less likely that dropping a lamp will cause cave-ins. also slowed down the propagation of dust slightly. --- src/main.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 24f3829..2daf153 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -358,11 +358,13 @@ void recalculateLighting(Game& game, fov_settings_type* fov) fov_settings_set_apply_lighting_function( fov, - [] (void* data, int x, int y, int dx, int dy, void*) { + [] (void* data, int x, int y, int dx, int dy, void* source) { Game& game = *static_cast(data); if (game.map.inBounds(x, y)) { + double lightRadius = static_cast(*static_cast(source)); + if (!game.map.at(x,y).lit) { game.litSpots++; @@ -375,7 +377,7 @@ void recalculateLighting(Game& game, fov_settings_type* fov) std::pow( std::max( 0.0, - 1.0 - std::sqrt(dx * dx + dy * dy) / static_cast(RADIUS)), + 1.0 - std::sqrt(dx * dx + dy * dy) / lightRadius), 1.0/3.0)); } }); @@ -388,7 +390,24 @@ void recalculateLighting(Game& game, fov_settings_type* fov) game.map.at(x,y).tile == Tile::Dust || game.map.at(x,y).tile == Tile::Lamp) { - fov_circle(fov, static_cast(&game), nullptr, x, y, RADIUS); + int lightRadius; + + if ((game.player_x == x && game.player_y == y && game.renderPlayer) || + game.map.at(x,y).tile == Tile::Lamp) + { + lightRadius = RADIUS; + } else if (game.map.at(x,y).tile == Tile::Dust) + { + lightRadius = 2; + } + + fov_circle( + fov, + static_cast(&game), + static_cast(&lightRadius), + x, + y, + lightRadius); game.map.at(x,y).lit = true; game.map.at(x,y).visibility = 1.0; @@ -646,7 +665,7 @@ int main(int, char**) Input keystate; SDL_Event e; - size_t dustDt = 30; + size_t dustDt = 40; size_t dustAcc = 0; size_t inputDt = 50; -- cgit 1.4.1