More cleanup then starting to sort out how to make systems extensible easily.
This commit is contained in:
parent
6a0c9e8d46
commit
cbff127b40
13 changed files with 106 additions and 769 deletions
|
|
@ -52,34 +52,3 @@ TEST_CASE("map placement test", "[map-fail]") {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("map image test", "[map]") {
|
||||
GameDB::init();
|
||||
|
||||
auto& level = GameDB::current_level();
|
||||
Matrix map_tiles = matrix::make(7,7);
|
||||
EntityGrid entity_map;
|
||||
|
||||
auto render = std::make_shared<sf::RenderTexture>();
|
||||
sf::Sprite sprite{render->getTexture()};
|
||||
auto player = level.world->get_the<components::Player>();
|
||||
auto& player_pos = level.world->get<components::Position>(player.entity);
|
||||
auto player_display = level.world->get<components::Tile>(player.entity).display;
|
||||
|
||||
for(matrix::each_row it{level.map->walls()}; it.next();) {
|
||||
player_pos.location.x = it.x;
|
||||
player_pos.location.y = it.y;
|
||||
System::draw_map(map_tiles, entity_map);
|
||||
System::render_map(map_tiles, entity_map, *render, 2, player_display);
|
||||
|
||||
// randomly test about 80% of them
|
||||
if(Random::uniform(0, 100) < 20) break;
|
||||
|
||||
#ifdef TEST_RENDER
|
||||
// confirm we get two different maps
|
||||
auto out_img = render->getTexture().copyToImage();
|
||||
bool worked = out_img.saveToFile(fmt::format("tmp/map_render{}{}.png", it.x, it.y));
|
||||
REQUIRE(worked);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue