Map is now cleaned out of anything not directly related to the map, and there's a new WorldBuilder class that will turn into a more sophisticated random world generator.
This commit is contained in:
parent
3f7a9cc124
commit
68d8bdce12
8 changed files with 296 additions and 266 deletions
|
@ -1,8 +1,8 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include "map.hpp"
|
||||
#include <fmt/core.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <fstream>
|
||||
#include "map.hpp"
|
||||
|
||||
using namespace fmt;
|
||||
using namespace nlohmann;
|
||||
|
@ -40,39 +40,3 @@ TEST_CASE("dijkstra algo test", "[map]") {
|
|||
// FIX ME: REQUIRE(paths == expected);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("bsp algo test", "[map]") {
|
||||
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("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);
|
||||
}
|
||||
|
|
51
tests/worldbuilder.cpp
Normal file
51
tests/worldbuilder.cpp
Normal file
|
@ -0,0 +1,51 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <fmt/core.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <fstream>
|
||||
#include "map.hpp"
|
||||
#include "worldbuilder.hpp"
|
||||
|
||||
using namespace fmt;
|
||||
using namespace nlohmann;
|
||||
using std::string;
|
||||
|
||||
TEST_CASE("bsp algo test", "[map]") {
|
||||
Map map(20, 20);
|
||||
WorldBuilder builder(map);
|
||||
builder.generate();
|
||||
}
|
||||
|
||||
TEST_CASE("dumping and debugging", "[map]") {
|
||||
Map map(20, 20);
|
||||
WorldBuilder builder(map);
|
||||
builder.generate();
|
||||
|
||||
dump_map("GENERATED", map.paths());
|
||||
map.dump();
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("camera control", "[map]") {
|
||||
Map map(20, 20);
|
||||
WorldBuilder builder(map);
|
||||
builder.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);
|
||||
WorldBuilder builder(map);
|
||||
builder.generate();
|
||||
|
||||
REQUIRE(map.can_move({0,0}) == false);
|
||||
REQUIRE(map.iswall(0,0) == true);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue