xxxxxxxxxx
47
// The Nature of Code
// Daniel Shiffman
// http://natureofcode.com
// Making sure pairs of particles are not checked twice
let palette = [
[11, 106, 136],
[45, 197, 244],
[112, 50, 126],
[146, 83, 161],
[164, 41, 99],
[236, 1, 90],
[240, 99, 164],
[241, 97, 100],
[248, 158, 79],
[252, 238, 33],
];
let physicsEngine;
function setup() {
createCanvas(700, 700);
physicsEngine = new PhysicsEngine();
for (let i = 0; i < 1000; i++) {
let x = random(width);
let y = random(height);
let smol = random(4, 500);
let bigboi = random(500, 10000);
let mass;
if (random(1, 30) > 20)
{
mass = bigboi;
}
else {
mass = smol;
}
physicsEngine.addParticle(new Particle(x, y, mass, i));
}
}
function draw() {
background(0);
physicsEngine.update();
}