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

@ -64,3 +64,19 @@ FoundEntities SpatialMap::neighbors(Point cell, bool diag) const {
return {!result.empty(), result};
}
SortedEntities SpatialMap::distance_sorted(Point from) {
SortedEntities sprite_distance;
for(const auto &rec : table) {
Point sprite = rec.first;
int inside = (from.x - sprite.x) * (from.x - sprite.x) +
(from.y - sprite.y) * (from.y - sprite.y);
sprite_distance.push_back({inside, rec.second});
}
std::sort(sprite_distance.begin(), sprite_distance.end());
return sprite_distance;
}