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:
parent
a67d25ee10
commit
cbf0955786
11 changed files with 93 additions and 65 deletions
|
@ -44,13 +44,13 @@ TEST_CASE("basic matrix iterator", "[matrix:basic]") {
|
|||
row_count += box.x == box.left;
|
||||
walls[box.y][box.x] = 3;
|
||||
}
|
||||
matrix::dump("2,2 WALLS", walls, 2, 2);
|
||||
//matrix::dump("2,2 WALLS", walls, 2, 2);
|
||||
|
||||
REQUIRE(row_count == 3);
|
||||
}
|
||||
|
||||
{
|
||||
matrix::dump("1:1 POINT", walls, 1,1);
|
||||
// matrix::dump("1:1 POINT", walls, 1,1);
|
||||
// confirm boxes have the right number of rows
|
||||
// when x goes to 0 on first next call
|
||||
row_count = 0;
|
||||
|
@ -68,7 +68,7 @@ TEST_CASE("basic matrix iterator", "[matrix:basic]") {
|
|||
println("START IS {},{}=={}", star.x, star.y, walls[star.y][star.x]);
|
||||
walls[star.y][star.x] = 11;
|
||||
}
|
||||
matrix::dump("STAR POINT", walls, 1,1);
|
||||
// matrix::dump("STAR POINT", walls, 1,1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,10 +115,10 @@ TEST_CASE("thrash box distance iterators", "[matrix:distance]") {
|
|||
result[box.y][box.x] = box.distance();
|
||||
}
|
||||
|
||||
matrix::dump(format("MAP {}x{} @ {},{}; BOX {}x{}; size: {}",
|
||||
matrix::width(result), matrix::height(result),
|
||||
target.x, target.y, box.right - box.left, box.bottom - box.top, size),
|
||||
result, target.x, target.y);
|
||||
// matrix::dump(format("MAP {}x{} @ {},{}; BOX {}x{}; size: {}",
|
||||
// matrix::width(result), matrix::height(result),
|
||||
// target.x, target.y, box.right - box.left, box.bottom - box.top, size),
|
||||
// result, target.x, target.y);
|
||||
}
|
||||
|
||||
TEST_CASE("thrash box iterators", "[matrix]") {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue