SpatialMap now uses unordered_multimap to allow for multiple items in a square, but they're also tagged to mark some with collision.
This commit is contained in:
parent
b193bab148
commit
f26189c696
6 changed files with 60 additions and 51 deletions
|
@ -37,7 +37,7 @@ TEST_CASE("confirm basic collision operations", "[collision]") {
|
|||
REQUIRE(nearby[0] == player);
|
||||
|
||||
{ // removed
|
||||
collider.remove({11,11});
|
||||
collider.remove({11,11}, player);
|
||||
auto [found, nearby] = collider.neighbors({10,10}, true);
|
||||
REQUIRE(!found);
|
||||
REQUIRE(nearby.empty());
|
||||
|
@ -141,7 +141,7 @@ TEST_CASE("check all diagonal works", "[collision]") {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE("confirm can iterate through all", "[spatialmap-sort]") {
|
||||
TEST_CASE("confirm can iterate through all", "[collision]") {
|
||||
DinkyECS::World world;
|
||||
SpatialMap collider;
|
||||
Point player{10,10};
|
||||
|
@ -154,7 +154,9 @@ TEST_CASE("confirm can iterate through all", "[spatialmap-sort]") {
|
|||
size_t y = Random::uniform<size_t>(0, 251);
|
||||
|
||||
Entity ent = world.entity();
|
||||
collider.insert({x,y}, ent, true);
|
||||
if(!collider.occupied({x, y})) {
|
||||
collider.insert({x,y}, ent, true);
|
||||
}
|
||||
}
|
||||
|
||||
auto sprite_distance = collider.distance_sorted(player, 1000);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue