xxxxxxxxxx
42
var Engine = Matter.Engine,
Render = Matter.Render,
World = Matter.World,
Bodies = Matter.Bodies;
var engine;
var world;
var circles = [];
var boundaries = [];
function setup() {
createCanvas(400, 400);
engine = Engine.create();
world = Engine.world;
Engine.run(engine);
boundaries.push(new Boundary(200, 400, 400, 20)); //底の壁生成
boundaries.push(new Boundary(0, 0, 20, 800)); //左端の壁生成
boundaries.push(new Boundary(400, 0, 20, 800)); //右端の壁生成
let count = 0;
const autoDrop = () => {
circles.push(new Circle(random(400), // x座標
random(100), // y座標
random(5, 5), // ボールの大きさ
"#FFFFFF")); // 色
setTimeout(autoDrop, 1000);
};
autoDrop();
}
function mouseClicked() {}
function draw() {
background(51);
Engine.update(engine);
for (var i = 0; i < circles.length; i++) {
circles[i].show();
}
for (var i = 0; i < boundaries.length; i++) {
boundaries[i].show();
}
}