-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rope.js
37 lines (27 loc) · 796 Bytes
/
Rope.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Rope {
constructor(body1,body2,offsetX,offsetY) {
this.offsetX = offsetX;
this.offsetY = offsetY ;
var options = {
bodyA:body1,
bodyB:body2 ,
pointB:{x:this.offsetX, y:this.offsetY} ,
}
this.Rope = Constraint.create(options);
World.add(world,this.Rope);
}
display () {
var pointA= this.Rope.bodyA.position;
var pointB= this.Rope.bodyB.position;
//stroke(0);
strokeWeight (1)
var Anchor1X = pointA.x
var Anchor1Y = pointA.y
stroke("red")
strokeWeight("4");
noFill();
var Anchor2X = pointB.x+this.offsetX
var Anchor2Y = pointB.y+this.offsetY
line (Anchor1X,Anchor1Y,Anchor2X,Anchor2Y);
}
}