@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); } }
public Blob() { pos = Point.frand(400, 400); clip = new ClipRect(12, 12); }
@Override public void update() { vel.add(Point.frand(0.01, 0.01)); vel.multiply(0.9); super.update(); }
public void update() { pos.add(vel); }