#include "World.h"
+#include "Collision.h"
#include "../graphics/const.h"
for (Vector<int> pos(cBegin); pos.y < cEnd.y; ++pos.y) {
for (pos.x = cBegin.x; pos.x < cEnd.x; ++pos.x) {
if (!TileAt(pos).IsSolid()) continue;
- const AABB tBounds(pos, Vector<float>(1, 1));
- Vector<float> pos;
- Vector<float> norm;
- Vector<float> depth;
- if (!e.bounds.Intersects(tBounds, pos, norm, depth)) {
+ const AABB &tBounds = TileShapeAt(pos);
+ Collision coll;
+ if (!e.bounds.Intersects(tBounds, coll)) {
continue;
}
- if (depth.x < min.x) min.x = depth.x;
- if (depth.x > max.x) max.x = depth.x;
- if (depth.y < min.y) min.y = depth.y;
- if (depth.y > max.y) max.y = depth.y;
+ if (coll.depth.x < min.x) min.x = coll.depth.x;
+ if (coll.depth.x > max.x) max.x = coll.depth.x;
+ if (coll.depth.y < min.y) min.y = coll.depth.y;
+ if (coll.depth.y > max.y) max.y = coll.depth.y;
}
}
}
+const AABB &World::TileShapeAt(Vector<int> pos) const {
+ tileShape = AABB(pos, Vector<float>(1, 1));
+ return tileShape;
+}
+
+
Entity &World::AddEntity(const Entity &e) {
entities.emplace_back(e);
return entities.back();