xxxxxxxxxx
36
let particles = [];
let instructions;
let speed = 0.5;
function setup() {
canvas = createCanvas(600, 600);
for (let i = 0; i < 600 / 2; i++) {
particles[i] = new Particle(random(width),random(height));
}
}
function draw() {
clear();
for (let i = 0; i < particles.length; i++) {
particles[i].show();
particles[i].move();
particles[i].bounce();
for (let j = 0; j < particles.length; j++) {
if (particles[i].isCloseTo(particles[j]) && particles[i] !== particles[j]) {
particles[i].createLineWith(particles[j]);
}
}
// if (particles[i].leavesBoundary) {
// particles.splice(particle[i], 1);
// }
}
}
function mousePressed() {
let mouseParticle = new Particle(mouseX, mouseY, 0, 255);
particles.push(mouseParticle);
}