]> git.localhorst.tv Git - orbi.git/blobdiff - src/world/World.cpp
entity/entity collision stub
[orbi.git] / src / world / World.cpp
index c76f8608bb82b30c4aaadda76413658df2fe0999..aa17319cd8dfca6cd9e91d1fcddd7b66ce0e064c 100644 (file)
@@ -6,6 +6,8 @@
 #include <algorithm>
 #include <cmath>
 
+using namespace std;
+
 
 namespace orbi {
 
@@ -126,6 +128,22 @@ void World::TileCollision(Entity &e, float dt) {
        e.Move(response);
 }
 
+void World::EntityCollision() {
+       if (entities.size() <= 1) return;
+
+       auto firstEnd(entities.end());
+       --firstEnd;
+       for (auto first(entities.begin()); first != firstEnd; ++first) {
+               auto second(first);
+               ++second;
+               for (auto secondEnd(entities.end()); second != secondEnd; ++second) {
+                       if (first->bounds.Intersects(second->bounds)) {
+                               // damage + knockback
+                       }
+               }
+       }
+}
+
 
 const AABB &World::TileShapeAt(Vector<int> pos) const {
        tileShape = AABB(pos, Vector<float>(1, 1));