xxxxxxxxxx
33
// noprotect
var main = [];
var tree = [];
var total;
var maxLen;
function setup(){
createCanvas(400, 400, P2D);
colorMode(HSB, 255);
total = floor((width + height));
for(var i = 0; i < total; i++){
main.push(new Particle(createVector(random(width), random(height)), false, 4));
}
tree.push(new Particle(createVector(width/2, height/2), true, 4));
maxLen = width/2;
}
function draw(){
background('#009966');
for(var i = 0; i < tree.length; i++){
var temp = tree[i];
temp.show(color(map(p5.Vector.dist(temp.pos, tree[0].pos), 0, maxLen, 0, 255), 200, 230));
}
for(var k = 0; k < main.length; k++){
var particle = main[k];
for(var j = 0; j < 20; j++){
particle.update();
particle.collide(tree);
}
}
}