Raycaster now controls the sprite locations with SpatialMap rather than the old way. Quick hack job in main.cpp that shows how they can move too.

This commit is contained in:
Zed A. Shaw 2025-02-01 14:39:08 -05:00
parent a67d25ee10
commit cbf0955786
11 changed files with 93 additions and 65 deletions

View file

@ -3,6 +3,7 @@
#include <string>
#include "spatialmap.hpp"
#include "dinkyecs.hpp"
#include "rand.hpp"
using DinkyECS::Entity;
using namespace fmt;
@ -135,3 +136,29 @@ TEST_CASE("check all diagonal works", "[collision]") {
}
}
}
TEST_CASE("confirm can iterate through all", "[spatialmap-sort]") {
DinkyECS::World world;
SpatialMap collider;
Point player{10,10};
for(int i = 0; i < 10; i++) {
size_t max = Random::uniform<size_t>(2,30);
for(size_t i = 0; i < max; i++) {
size_t x = Random::uniform<size_t>(0, 213);
size_t y = Random::uniform<size_t>(0, 251);
Entity ent = world.entity();
collider.insert({x,y}, ent);
}
auto sprite_distance = collider.distance_sorted(player);
int prev_dist = 0;
for(auto dist : sprite_distance) {
REQUIRE(prev_dist <= dist.first);
prev_dist = dist.first;
}
}
}