-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbob.js
More file actions
27 lines (23 loc) · 846 Bytes
/
Copy pathbob.js
File metadata and controls
27 lines (23 loc) · 846 Bytes
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
//the bob class
class Bob{
constructor(x, y, radius){
var properties = {
//some changes in the properties of the bob
isStatic: false,
friction:0.1,
density:0.1,
restitution: 1
}
this.body = Bodies.circle(x, y, radius, properties);//creates the bob according to the physics engine
this.diameter = radius*2;
this.x = x;
this.y = y;
World.add(world, this.body);//adds this bob to the world so that it acts according to the physics laws
}
display(){
//function for displaying the bob
var position = this.body.position;//name spacing
fill(255, 0, 255);//colours it pink
ellipse(position.x, position.y, this.diameter, this.diameter); //draws an ellipse over the body created above
}
}