#include #include #include #include #include "map.hpp" #include "worldbuilder.hpp" #include "lights.hpp" #include "point.hpp" using namespace lighting; TEST_CASE("lighting a map works", "[lighting]") { Map map(20,23); WorldBuilder builder(map); builder.generate(); Point light1 = map.place_entity(0); Point light2 = map.place_entity(1); LightSource source1{0,2}; LightSource source2{1,3}; LightRender lr(map.width(), map.height()); lr.reset_light(); lr.set_light_target(light1); lr.set_light_target(light2); lr.path_light(map.walls()); lr.render_light(source1, light1); lr.render_light(source2, light2); lr.clear_light_target(light1); lr.clear_light_target(light2); Matrix &lighting = lr.lighting(); matrix::dump("WALLS=====", map.walls(), light1.x, light1.y); matrix::dump("LIGHTING======", lighting, light1.x, light1.y); // confirm light is set at least at and around the two points REQUIRE(lighting[light1.y][light1.x] == lighting::LEVELS[source1.strength]); REQUIRE(lighting[light2.y][light2.x] == lighting::LEVELS[source2.strength]); }