FoW is now moved into lighting so light determines what's seen not player's last position. Not sure if I like that though.

This commit is contained in:
Zed A. Shaw 2025-07-21 13:10:03 -04:00
parent d264760405
commit 2997dc363b
7 changed files with 19 additions and 30 deletions

View file

@ -24,8 +24,7 @@ namespace gui {
$level(level),
$map_render(std::make_shared<sf::RenderTexture>()),
$map_sprite($map_render->getTexture()),
$map_tiles(matrix::make(MAP_WIDTH, MAP_HEIGHT)),
$fow(matrix::make($level.map->width(), $level.map->height()))
$map_tiles(matrix::make(MAP_WIDTH, MAP_HEIGHT))
{
auto player = $level.world->get_the<Player>();
$player_display = $level.world->get<Tile>(player.entity).display;
@ -33,7 +32,6 @@ namespace gui {
void MapViewUI::update_level(GameLevel &level) {
$level = level;
$fow = matrix::make($level.map->width(), $level.map->height());
}
void MapViewUI::init() {
@ -62,19 +60,8 @@ namespace gui {
void MapViewUI::render(sf::RenderWindow &window, int compass_dir) {
$gui.render(window);
auto player = $level.world->get_the<components::Player>();
auto player_pos = $level.world->get<components::Position>(player.entity).location;
// NOTE: FoW is probably better done in the lighting system, because it illuminates where you've been. The light calcs could then simply set the light the player touches to 1 when it's run.
for(matrix::circle it{$fow, player_pos, 2.5}; it.next();) {
for(int x = it.left; x < it.right; x++) {
$fow[it.y][x] = 1;
}
}
System::draw_map($level, $map_tiles, $fow, $entity_map);
System::render_map($map_tiles, $entity_map, *$map_render, compass_dir, $player_display);
System::draw_map($level, $map_tiles, $entity_map);
System::render_map($level, $map_tiles, $entity_map, *$map_render, compass_dir, $player_display);
$map_sprite.setTexture($map_render->getTexture(), true);
window.draw($map_sprite);
// $gui.debug_layout(window);