xxxxxxxxxx
35
const Engine = Matter.Engine;
const Bodies = Matter.Bodies;
const World = Matter.World;
let ground;
let boxes = [];
let world;
let engine;
function setup() {
createCanvas(400, 400);
engine = Engine.create();
world = engine.world;
// world.gravity.x = 1;
// world.gravity.y = 0;
ground = new Boundary(0, 380, 400, 20);
box = new Box(300, 200, 10, 10);
boxes.push(box);
}
function mousePressed() {
box = new Box(mouseX, mouseY, 10, 10);
boxes.push(box);
}
function draw() {
background(0);
Engine.update(engine);
ground.show();
for (let box of boxes) {
box.show();
}
}