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
|
@ -8,7 +8,8 @@
|
|||
typedef std::vector<DinkyECS::Entity> EntityList;
|
||||
|
||||
// Point's has is in point.hpp
|
||||
typedef std::unordered_map<Point, DinkyECS::Entity> PointEntityMap;
|
||||
using PointEntityMap = std::unordered_map<Point, DinkyECS::Entity>;
|
||||
using SortedEntities = std::vector<std::pair<int, DinkyECS::Entity>>;
|
||||
|
||||
struct FoundEntities {
|
||||
bool found;
|
||||
|
@ -18,6 +19,7 @@ struct FoundEntities {
|
|||
class SpatialMap {
|
||||
public:
|
||||
SpatialMap() {}
|
||||
PointEntityMap table;
|
||||
|
||||
void insert(Point pos, DinkyECS::Entity obj);
|
||||
void move(Point from, Point to, DinkyECS::Entity ent);
|
||||
|
@ -26,6 +28,6 @@ class SpatialMap {
|
|||
DinkyECS::Entity get(Point at) const;
|
||||
FoundEntities neighbors(Point position, bool diag=false) const;
|
||||
|
||||
private:
|
||||
PointEntityMap table;
|
||||
SortedEntities distance_sorted(Point from);
|
||||
size_t size() { return table.size(); }
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue