-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDynamic.js
More file actions
42 lines (40 loc) · 1.09 KB
/
Dynamic.js
File metadata and controls
42 lines (40 loc) · 1.09 KB
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
class Dynamic extends parent {
constructor(x,y,dirx,diry,vx,vy,id) {
super(x,y,id);
this.dirx = dirx;
this.diry = diry;
this.vx = vx;
this.vy = vy;
}
roi() {
this.vy -= 0.8;
this.y += this.vy;
}
// move() {
// // this.x += this.dirx * this.vx;
// // this.y += this.diry * this.vy;
// // this.vx--;
// // if (this.vy > 0 ) this.vy- =5;
// }
fall() {
if (this.dirx == -1) {
for(var i=first; i < last ; i++) {
if (list_obj[i] != this && this.y - list_obj[i].y == 50 && inside(list_obj[i].x-trai,list_obj[i].y,this.x-trai-this.vx,this.y-0.01)) {
// x-trai-thiss.x = list_obj[i].x + 50;
// this.dirx = -1 * this.dirx;
return false;
}
}
} else {
for(var i=first; i < last ; i++) {
if (list_obj[i] != this && this.y - list_obj[i].y == 50 && inside(list_obj[i].x-trai+this.vx,list_obj[i].y,this.x-trai+49.9999+this.vx,this.y-0.01)) {
// this.x = list_obj[i].x - 50;
// this.dirx = -1 * this.dirx;
return false;
}
}
}
this.dirx = -1 * this.dirx;
return true;
}
}