X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FWorld.cpp;h=a198ccc77a2f06b17ea49c6b4806f392f3d6448a;hb=a73a6dd63407b5f5ef5b0c635551ad27b27c95d6;hp=faf7da910b5a34420bf5fdc13c55d5c7f625ed36;hpb=7fccdf2cd07afb3afdc0b854e9a03130ef202eec;p=orbi.git diff --git a/src/world/World.cpp b/src/world/World.cpp index faf7da9..a198ccc 100644 --- a/src/world/World.cpp +++ b/src/world/World.cpp @@ -1,6 +1,7 @@ #include "World.h" #include "Collision.h" +#include "Entity.h" #include "../graphics/const.h" #include @@ -23,16 +24,16 @@ World::World(Vector size) void World::Update(float dt) { - for (Entity &e : entities) { - if (e.onGround) { - e.Update(dt, Vector(), terminal); - e.onGround = false; + for (Entity *e : entities) { + if (e->onGround) { + e->Update(dt, Vector(), terminal); + e->onGround = false; } else { - e.Update(dt, gravity, terminal); + e->Update(dt, gravity, terminal); } - BoundsCollision(e, dt); - TileCollision(e, dt); + BoundsCollision(*e, dt); + TileCollision(*e, dt); } } @@ -159,7 +160,7 @@ void World::EntityCollision() { auto second(first); ++second; for (auto secondEnd(entities.end()); second != secondEnd; ++second) { - if (first->bounds.Intersects(second->bounds)) { + if ((*first)->bounds.Intersects((*second)->bounds)) { // damage + knockback } } @@ -167,9 +168,4 @@ void World::EntityCollision() { } -Entity &World::AddEntity(const Entity &e) { - entities.emplace_back(e); - return entities.back(); -} - }