xxxxxxxxxx
let monster;
let mallet;
let anchor1;
let anchor2;
let topJoint, bottomJoint;
function setup() {
new Canvas(windowWidth, windowHeight);
monster = new Sprite();
monster.width = 100;
monster.height = 100;
monster.image = 'micro.png';
monster.image.offset.y = 6;
monster.image.scale = 0.5;
mallet = new Sprite();
mallet.width = 10;
mallet.height = 50;
mallet.x = 0;
anchor1 = new Sprite(width/2, 200, 10, 10, 'static');
anchor2 = new Sprite(width/2, height-200, 10, 10, 'static');
topJoint = new DistanceJoint(anchor1, monster);
topJoint.offsetA.y = 5;
topJoint.collideConnected = true;
//topJoint.springiness = 0.01;
bottomJoint = new DistanceJoint(anchor2, monster);
bottomJoint.offsetA.y = 5;
bottomJoint.collideConnected = true;
}
function draw() {
clear();
mallet.moveTowards(mouse, 0.10);
monster.rotation = 0;
}