-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspaceship.js
37 lines (31 loc) · 835 Bytes
/
spaceship.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
let collector_Types = ['household_food_waste','residual_waste','recyclable_waste','hazardous_waste'];
export class spaceship {
constructor(x, y){
this.x = x;
this.y = y;
}
getX() {
return this.x;
}
getY() {
return this.y;
}
setCollectorType(t) {
this.type = collector_Types[t];
}
getCollectorType() {
return this.type;
}
getDistance(a, b) {
return Math.sqrt(Math.pow(a.getX() - b.getX(), 2) +
Math.pow(a.getY() - b.getY(), 2));
}
onCollisionWith(g) {
return (getDistance(this, g) < 10)
}
// collect garbage method, put it in something like update()
// for all garbage in canvas:
// if this.onCollisionWith(garbage):
// remove garbage from canvas
// increment score
}