diff --git a/chp06_agents/box2d/Flocking_box2d/Boid.pde b/chp06_agents/box2d/Flocking_box2d/Boid.pde index cb001acc..b2d06fa9 100644 --- a/chp06_agents/box2d/Flocking_box2d/Boid.pde +++ b/chp06_agents/box2d/Flocking_box2d/Boid.pde @@ -47,17 +47,17 @@ class Boid { ali.mulLocal(1); coh.mulLocal(1); // Add the force vectors to acceleration - Vec2 loc = body.getWorldCenter(); - body.applyForce(sep,loc); - body.applyForce(ali,loc); - body.applyForce(coh,loc); + Vec2 pos = body.getWorldCenter(); + body.applyForce(sep,pos); + body.applyForce(ali,pos); + body.applyForce(coh,pos); } // A method that calculates and applies a steering force towards a target // STEER = DESIRED MINUS VELOCITY Vec2 seek(Vec2 target) { - Vec2 loc = body.getWorldCenter(); - Vec2 desired = target.sub(loc); // A vector pointing from the position to the target + Vec2 pos = body.getWorldCenter(); + Vec2 desired = target.sub(pos); // A vector pointing from the position to the target // If the magnitude of desired equals 0, skip out of here // (We could optimize this to check if x and y are 0 to avoid mag() square root @@ -102,7 +102,7 @@ class Boid { // Wraparound void borders() { - Vec2 loc = box2d.getBodyPixelCoord(body); + Vec2 pos = box2d.getBodyPixelCoord(body); Vec2 vel = body.getLinearVelocity(); float a = body.getAngularVelocity(); if (pos.x < -w) { @@ -254,4 +254,3 @@ class Boid { } -