-
Notifications
You must be signed in to change notification settings - Fork 0
/
ball.js
62 lines (50 loc) · 801 Bytes
/
ball.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class Ball {
constructor(x = 0, y = 0, floor = 0) {
this.x = x;
this.y = y;
this.size = 20;
this.floor = floor
this.hitAgent = false
}
fall() {
if (this.y < this.floor) {
this.y += 25
}
}
hitTheFloor() {
if (this.y >= this.floor) {
return true
}
return false
}
draw() {
fill(51);
circle(this.x, this.y, this.size);
}
getY() {
return this.y
}
getX() {
return this.x
}
getCoord() {
return {
x: Math.floor(this.x),
y: Math.floor(this.y)
}
}
diameter() {
return this.size
}
radius() {
return Math.floor(this.size / 2)
}
sethitAgent() {
this.hitAgent = true
}
doesHitAgent() {
stroke('#222222');
strokeWeight(4);
return this.hitAgent
}
}