xxxxxxxxxx
34
let ps;
let world;
let boundaries = []
function setup() {
angleMode(DEGREES);
createCanvas(400, 400);
world = createWorld();
// Add a bunch of fixed boundaries
boundaries.push(new Boundary(width / 4, height - 5, width / 2 - 50, 10,0));
boundaries.push(new Boundary(3 * width / 4, height - 50, width / 2 - 50, 10,0));
ps = new ParticleSystem();
}
function draw() {
background(220);
// We must always step through time!
let timeStep = 1.0 / 30;
// 2nd and 3rd arguments are velocity and position iterations
world.Step(timeStep, 10, 10);
// Display all the boundaries
for (let i = 0; i < boundaries.length; i++) {
// rotate(30*i);
boundaries[i].display();
}
ps.run();
}
function mousePressed() {
ps.create(mouseX,mouseY);
}