-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyedek.js
executable file
·68 lines (57 loc) · 1.63 KB
/
yedek.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
63
64
65
66
67
68
var traveler = function(positionVector){
this.position = positionVector;
}
traveler.prototype.moveX = function(){
this.position.x = this.position.x+1;
}
traveler.prototype.moveY = function(){
this.position.y = this.position.y+1;
}
traveler.prototype.moveUntilX = function(xLimit){
if( this.position.x == xLimit){
return;
} else {
this.position.x = this.position.x+1;
}
}
traveler.prototype.moveToHorizontalSibling = function(xLimit){
if(this.position.x === xLimit){
console.log("hor",xLimit,this.position.x);
currentNode=currentNode+1;
return;
} else {
if(xLimit > this.position.x){
this.position.x = this.position.x+1;
} else {
this.position.x = this.position.x-1;
}
}
}
traveler.prototype.moveToVerticalSibling = function(yLimit){
if( this.position.y == yLimit){
console.log("ver")
currentNode=currentNode+1;
return;
} else {
if(yLimit > this.position.y){
this.position.y = this.position.y+1;
} else {
this.position.y = this.position.y-1;
}
}
}
// traveler.prototype.moveToNextNode = function(node){
// //move
// if(this.position.y == node.y){
// this.moveToHorizontalSibling(node.x);
// } else if(this.position.x == node.x){
// this.moveToVerticalSibling(node.y);
// }
// }
traveler.prototype.moveThroughNodes = function(nodesList){ //nodesList array of vector objects
for(var i=0; i<nodesList.length; i++){
var node = nodesList[i];
console.log(node);
this.moveToNextNode(node);
}
}