- const Vector<int> cBegin(b.Left(), b.Top());
- const Vector<int> cEnd(b.Right(), b.Bottom());
+void World::BoundsCollision(Entity &e, float dt) {
+ if (e.vbox.Top() < 0) {
+ e.Move(Vector<float>(0, -e.vbox.Top()));
+ if (e.vel.y < 0) {
+ e.vel.y = 0;
+ }
+ }
+ if (e.vbox.Bottom() > size.y) {
+ e.Move(Vector<float>(0, size.y - e.vbox.Bottom()));
+ if (e.vel.y > 0) {
+ e.vel.y = 0;
+ }
+ e.onGround = true;
+ }
+ if (e.hbox.Right() > size.x) {
+ e.Move(Vector<float>(size.x - e.hbox.Right(), 0));
+ if (e.vel.x > 0) {
+ e.vel.x = 0;
+ }
+ }
+ if (e.hbox.Left() < 0) {
+ e.Move(Vector<float>(-e.hbox.Left(), 0));
+ if (e.vel.x < 0) {
+ e.vel.x = 0;
+ }
+ }
+}