-
Notifications
You must be signed in to change notification settings - Fork 3
/
ground.js
43 lines (40 loc) · 1.12 KB
/
ground.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
37
38
39
40
41
42
43
// ************************************************
// Teugg Soccer Physics
// Rip-off of the once popular Soccer Physics game
// Horribly coded by : Kevin Le Teugg, 2020
// File : ground.js
// Description : Ground class used for defining the ground properties of the game
// ************************************************
class Ground {
constructor(x, y, w, h, a) {
this.x = x;
this.y = y;
this.h = h;
this.w = w;
var options = {
friction: 0.99,
restitution: 0.8,
isStatic: true,
collisionFilter: {
category: groundCollCategory,
mask: generalCollCategory | generalNoCollCategory
}
};
this.body = Bodies.rectangle(this.x, this.y, this.w, this.h, options);
this.body.position.x = this.x;
this.body.position.y = this.y;
this.body.angle = a; // in radians
// Adding the body to the world
World.add(world, this.body);
}
show() {
push();
rectMode(CENTER);
translate(this.body.position.x, this.body.position.y);
rotate(this.body.angle);
stroke(127);
fill(200, 150, 70);
rect(0, 0, this.w, this.h);
pop();
}
}