xxxxxxxxxx
73
let width = 400;
let height = 400;
let capturer;
let rry = [];
let num = 20;
let b;
let radius =100;
function setup() {
createCanvas(width,height);
rectMode(CENTER);
ellipseMode(CENTER);
for(let i=0; i<num;i++){
let l = floor(random(100,250));
let r = 250;
let angle = random(360);
let x = width/2 + cos(angle) * r;
let y = height/2 + sin(angle) * r;
let t = new Worm(x,y,l,90,0);
rry.push(t);
}
b = new Ball(width/2,height/2,200,5);
}
function draw() {
background(50,190);
angleMode(DEGREES);
b.update();
b.display();
b.checkEdges()
for(let i=0; i<rry.length; i++){
let v = rry[i].getPos();
push();
translate(v.x,v.y);
let v1 = b.getLocation();
let a = v.sub(v1).heading();
rotate(a);
rry[i].update(a);
rry[i].display(v);
pop();
}
}