#include "World.h"
#include "Collision.h"
+#include "Entity.h"
#include "../graphics/const.h"
#include <algorithm>
void World::Update(float dt) {
- for (Entity &e : entities) {
- if (e.onGround) {
- e.Update(dt, Vector<float>(), terminal);
- e.onGround = false;
+ for (Entity *e : entities) {
+ if (e->onGround) {
+ e->Update(dt, Vector<float>(), 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);
}
}
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
}
}
}
-Entity &World::AddEntity(const Entity &e) {
- entities.emplace_back(e);
- return entities.back();
-}
-
}