@Override public void forIntersecting(Collider c) { Point dist = new Point(c.pos.x - pos.x, c.pos.y - pos.y); double distance = dist.magnitude(); dist.normalize(); dist.multiply(-100 / ((distance * distance * distance) + 50)); vel.add(dist); }
@Override public void forAllOthers(Collider c) { Point dist = new Point(c.pos.x - pos.x, c.pos.y - pos.y); double distance = dist.magnitude(); if (distance > 20) { dist.normalize(); dist.multiply(10 / ((distance * distance) + 10)); vel.add(dist); } }