summaryrefslogtreecommitdiff
path: root/src/game/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r--src/game/game.cpp50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp
index 44ea95d..58b2c9d 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -194,7 +194,6 @@ void state_t::resume(void)
paused = false;
}
-
#define TIME_DELTA ((ntime_t)1000000000 / 60)
void state_t::tick(ntime_t time_)
@@ -234,6 +233,55 @@ void state_t::tick(ntime_t time_)
}
}
+void state_t::compute_ambience(render::state_t *render)
+{
+ rectf_t area;
+ size_t plains = 0, cave = 0, water = 0, weird = 0;
+ float scale, volume;
+
+ area = render->window_in_world_space();
+
+ // resolution chosen arbitrarily
+ for (size_t y = 0; y < 5; y++)
+ for (size_t x = 0; x < 5; x++) {
+ v2f_t point;
+ world::tile_t *tile;
+
+ point[0] = lerp(area[0][0], area[1][0], y / 4.0f);
+ point[1] = lerp(area[0][1], area[1][1], x / 4.0f);
+
+ tile = world.get_tile(world::tile_index_t(point), world::SECTOR_FULL);
+
+ switch (tile->type) {
+ case TILE_DIRT:
+ plains++;
+ break;
+
+ case TILE_GRAVEL:
+ case TILE_STONE:
+ cave++;
+ break;
+
+ case TILE_WATER:
+ water++;
+ break;
+
+ case TILE_DIRT_RED:
+ case TILE_STONE_RED:
+ weird++;
+ break;
+ }
+ }
+
+ scale = 1.0f / area.dims().len();
+ volume = clamp(remap(0.002f, 0.08f, 0.0f, 1.0f, scale), 0.0f, 1.0f);
+
+ assets::ambience.wind.weight = plains / 25.0f * volume;
+ assets::ambience.chasm.weight = cave / 25.0f * volume;
+ assets::ambience.water.weight = water / 25.0f * volume;
+ assets::ambience.nexus.weight = weird / 25.0f * volume;
+}
+
die_t::die_t(size_t sides_)
{
sides = sides_;