Hi I adapted this snippet of code from here However, despite the restitution, the objects aren’t bouncy at all. Is there anything I need to change?
// This example is based on examples from: http://brm.io/matter-js/
var Engine = Matter.Engine;
var Render = Matter.Render;
var World = Matter.World;
var Bodies = Matter.Bodies;
var Composite = Matter.Composite;
var engine;
var boxA;
var boxB;
var ground;
function setup() {
createCanvas(800, 600);
// create an engine
engine = Engine.create();
let options = {
isStatic: true,
restitution: 0.8
}
// create two boxes and a ground
boxA = Bodies.rectangle(400, 200, 80, 80);
//boxB = Bodies.circle(490, 50, 80, 80);
boxB = Bodies.circle(490, 50, 20, 20);
ground = Bodies.rectangle(400, 610, 810, 60, options);
World.add(engine.world, [boxA, boxB, ground]);
// run the engine
Engine.run(engine);
}
// Using p5 to render
function draw() {
// var bodies = Composite.allBodies(engine.world);
background(51);
var vertices = boxA.vertices;
fill(255);
beginShape();
for (var i = 0; i < vertices.length; i++) {
vertex(vertices[i].x, vertices[i].y);
}
endShape();
// boxB vertices
var vertices = boxB.vertices;
fill(255);
beginShape();
for (var i = 0; i < vertices.length; i++) {
vertex(vertices[i].x, vertices[i].y);
}
endShape();
// Ground vertices
var vertices = ground.vertices;
beginShape();
fill(127);
for (var i = 0; i < vertices.length; i++) {
vertex(vertices[i].x, vertices[i].y);
}
endShape();
}