xxxxxxxxxx
70
//Module Aliases
var World = Matter.World,
Bodies = Matter.Bodies,
Engine = Matter.Engine,
//Render = Matter.Render,
Constraint = Matter.Constraint,
mouseConstraint = Matter.MouseConstraint;
var engine;
var world;
//var render;
//var obj;
var weight1;
var frame;
function setup()
{
createCanvas(600, 600);
background('#D3D3D3');
//Create the engine
engine = Engine.create();
world = engine.world;
//Create the renderer
// render = Render.create({
// element: document.body,
// engine: engine
// });
// Render.run(render);
//Create a new weight
weight1 = new Weight(90, height/2, 70);
//Storing the distance between circle centres
var distance = (90 + weight1.r);
weight2 = new Weight(distance, height/2, 70);
weight3 = new Weight((distance + weight1.r), height/2, 70);
weight4 = new Weight(((distance + weight1.r) + weight1.r), height/2, 70);
//Create a new frame
frame = new Frame(50, 30, 300, 20, {isStatic: true});
console.log(frame);
console.log(weight1);
//Add it to the world
World.add(world, [weight1, frame]);
//frame = Bodies.rectangle(50, 30, 300, 20, {isStatic: true});
//weight1 = Bodies.circle(90, height/2, 30);
//obj = Bodies.rectangle(width/2, height/2, 80, 80);
//World.add(engine.world, [weight1, frame]);
//World.add(engine.world, obj);
}
function draw()
{
//Run the engine
Engine.run(engine);
weight1.show();
weight2.show();
weight3.show();
weight4.show();
frame.show();
}