Brought over a bunch of code from the roguelike and now will use it to generate a random map.
This commit is contained in:
parent
8d3d3b4ec3
commit
2daa1c9bd5
59 changed files with 4303 additions and 411 deletions
45
tests/lighting.cpp
Normal file
45
tests/lighting.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <fmt/core.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <fstream>
|
||||
#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_map();
|
||||
Point light1, light2;
|
||||
|
||||
REQUIRE(map.place_entity(0, light1));
|
||||
REQUIRE(map.place_entity(1, light1));
|
||||
|
||||
LightSource source1{6, 1.0};
|
||||
LightSource source2{4,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("PATHS=====", lr.paths(), light1.x, light1.y);
|
||||
matrix::dump("LIGHTING 1", lighting, light1.x, light1.y);
|
||||
matrix::dump("LIGHTING 2", lighting, light2.x, light2.y);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue