xxxxxxxxxx
41
// Daniel Shiffman
// https://youtu.be/uITcoKpbQq4
// module aliases
const Engine = Matter.Engine;
// const Render = Matter.Render;
const World = Matter.World;
const Bodies = Matter.Bodies;
let engine;
let world;
let circles = [];
let boundaries = [];
let ground;
function setup() {
createCanvas(400, 400);
engine = Engine.create();
world = engine.world;
//Engine.run(engine);
boundaries.push(new Boundary(150, 100, width * 0.6, 20, 0.3));
boundaries.push(new Boundary(250, 300, width * 0.6, 20, -0.3));
}
function mouseDragged() {
circles.push(new Circle(mouseX, mouseY, random(5, 10)));
}
function draw() {
background(0);
Engine.update(engine);
for (let i = 0; i < circles.length; i++) {
circles[i].show();
}
for (let i = 0; i < boundaries.length; i++) {
boundaries[i].show();
}
}