Now have good coverage on map but need to actually confirm results in the test.

main
Zed A. Shaw 5 days ago
parent 97255eb813
commit d0d62836e3
  1. 2
      Makefile
  2. 8
      map.cpp
  3. 2
      map.hpp
  4. 2
      status.txt
  5. 54
      tests/map.cpp

@ -30,4 +30,4 @@ debug:
gdb --nx -x .gdbinit builddir/roguish.exe
cover:
gcovr --html coverage/coverage_report.html --gcov-ignore-errors=no_working_dir_found --exclude "scratchpad.*" --exclude "subprojects.*" --html-nested coverage/
gcovr --html coverage/index.html --gcov-ignore-errors=no_working_dir_found --exclude "scratchpad.*" --exclude "subprojects.*" --html-nested coverage/

@ -295,10 +295,6 @@ void Map::set_target(const Point &at, int value) {
$input_map[at.y][at.x] = 0;
}
void Map::clear_light_target(const Point &at) {
$input_map[at.y][at.x] = 1;
}
void Map::clear_target(const Point &at) {
$input_map[at.y][at.x] = 1;
}
@ -386,6 +382,10 @@ void Map::reset_light() {
}
}
void Map::clear_light_target(const Point &at) {
$input_map[at.y][at.x] = 1;
}
void Map::set_light_target(const Point &at, int value) {
set_target(at, value);
}

@ -69,6 +69,7 @@ public:
void add_door(Room &room);
bool can_move(Point move_to);
void generate();
void set_door(Room &room, int value);
void place_rooms(Room &root);
Point place_entity(size_t room_index);
@ -79,7 +80,6 @@ public:
void set_target(const Point &at, int value=0);
void clear_target(const Point &at);
bool walk(Point &src, Point &target);
void set_door(Room &room, int value);
Point map_to_camera(const Point &loc, const Point &cam_orig);
Point center_camera(const Point &around, size_t view_x, size_t view_y);

@ -7,6 +7,8 @@ TODAY'S GOAL:
* Doxygen? Other docs tool?
TODO:
* I can do headless windows in renderer for testing.
- renderer.$window.setVisible(false);
* Think up an enemy system.
* Revisit map generation.
* Write a method for renderer that can translate coordinates.

@ -36,6 +36,58 @@ TEST_CASE("dijkstra algo test", "[map]") {
}
TEST_CASE("bsp algo test", "[map]") {
Map map(50, 20);
Map map(20, 20);
map.generate();
}
TEST_CASE("dumping and debugging", "[map]") {
Map map(20, 20);
map.generate();
dump_map("GENERATED", map.paths());
map.dump();
}
TEST_CASE("lighting test", "[map]") {
Map map(20,20);
map.generate();
Point light1 = map.place_entity(0);
Point light2 = map.place_entity(1);
LightSource source1{7,1};
LightSource source2{3,2};
map.reset_light();
map.set_light_target(light1);
map.set_light_target(light2);
map.path_light();
map.render_light(source1, light1);
map.render_light(source2, light2);
map.clear_light_target(light1);
map.clear_light_target(light2);
}
TEST_CASE("camera control", "[map]") {
Map map(20,20);
map.generate();
Point center = map.center_camera({10,10}, 5, 5);
REQUIRE(center.x == 8);
REQUIRE(center.y == 8);
Point translation = map.map_to_camera({10,10}, center);
REQUIRE(translation.x == 2);
REQUIRE(translation.y == 2);
}
TEST_CASE("pathing", "[map]") {
Map map(20,20);
map.generate();
REQUIRE(map.can_move({0,0}) == false);
REQUIRE(map.iswall(0,0) == true);
}

Loading…
Cancel
Save