@@ -18,7 +18,7 @@ export default class Node {
18
18
this . level = 0 ;
19
19
}
20
20
21
- setPosition = function ( ) {
21
+ setPosition ( ) {
22
22
this . position = new Vector ( this . parent . position . x + Random . range ( - 50 , 50 ) , this . parent . position . y + Random . range ( - 50 , 50 ) ) ;
23
23
}
24
24
@@ -27,7 +27,7 @@ export default class Node {
27
27
this . startDistance = Vector . distance ( this . position , this . destination ) ;
28
28
}
29
29
30
- setRandomDestination = function ( ) {
30
+ setRandomDestination ( ) {
31
31
var dX = 0 ;
32
32
var dY = 0 ;
33
33
if ( this . parent !== null ) {
@@ -43,11 +43,11 @@ export default class Node {
43
43
this . startDistance = Math . sqrt ( ( Math . pow ( this . position . x - this . destination . x , 2 ) + Math . pow ( this . position . y - this . destination . y , 2 ) ) ) ; ;
44
44
}
45
45
46
- getDestinationAngle = function ( ) {
46
+ getDestinationAngle ( ) {
47
47
return Math . atan2 ( ( this . destination . y - this . position . y ) , ( this . destination . x - this . position . x ) ) ;
48
48
}
49
49
50
- move = function ( ) {
50
+ move ( ) {
51
51
52
52
var distance = Math . sqrt ( ( Math . pow ( this . position . x - this . destination . x , 2 ) + Math . pow ( this . position . y - this . destination . y , 2 ) ) ) ;
53
53
var percent = 100 - ( ( distance / this . startDistance ) * 100 ) ;
@@ -74,7 +74,7 @@ export default class Node {
74
74
this . position . add ( velocity ) ;
75
75
} ;
76
76
77
- addChild = function ( childNode ) {
77
+ addChild ( childNode ) {
78
78
childNode . level = this . level + 1 ;
79
79
childNode . parent = this ;
80
80
childNode . setPosition ( ) ;
@@ -83,15 +83,15 @@ export default class Node {
83
83
this . children . push ( childNode ) ;
84
84
return childNode ;
85
85
}
86
- reachedTarget = function ( ) {
86
+ reachedTarget ( ) {
87
87
var distance = Math . sqrt ( ( Math . pow ( this . position . x - this . destination . x , 2 ) + Math . pow ( this . position . y - this . destination . y , 2 ) ) ) ;
88
88
if ( this . level === 0 ) {
89
89
return distance < 10 ;
90
90
}
91
91
return distance < 20 ;
92
92
}
93
93
94
- update = function ( ) {
94
+ update ( ) {
95
95
if ( this . reachedTarget ( ) ) {
96
96
if ( this . wait ) {
97
97
this . waitTime ++ ;
0 commit comments