xxxxxxxxxx
60
let walls = [];
let ray;
let particles = [];
var angle = 0;
var step;
var r = 10;
var xOff = 0;
var yOff = 100000;
function setup() {
createCanvas(windowWidth, windowHeight);
walls.push(new Boundary(0,0,width,0));
walls.push(new Boundary(width,0,width,height));
walls.push(new Boundary(width,height,0,height));
walls.push(new Boundary(0,height,0,0));
for(var i = 0; i < 10; i++){
walls.push(new Boundary(random(width),random(height),random(width),random(height)));
}
for(let a = 0; a < 9; a++){
particles.push(new Particle());
}
}
function draw() {
background(240);
step = TWO_PI/8;
for(let wall of walls){
wall.show();
}
var xNoise = noise(xOff) * width;
var yNoise = noise(yOff) * height;
xOff += 0.01;
yOff += 0.01;
particles[0].update(xNoise,yNoise);
for(var i = 1; i < particles.length; i++){
let x = r * sin(angle);
let y = r * cos(angle);
particles[i].update(xNoise+x,yNoise+y);
angle = angle + step;
}
for(let particle of particles){
particle.show();
particle.look(walls);
}
//ray.show();
//ray.lookAt(mouseX,mouseY);
//let pt = ray.cast(wall);
//if(pt){
// fill(255);
// ellipse(pt.x,pt.y,10,10);
//}
}