-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKendaniEak.js
executable file
·33 lines (32 loc) · 1.04 KB
/
KendaniEak.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
class KendaniEak {
constructor(x,y,index){
this.index = index;
this.x = x;
this.y = y;
this.energy = 10;
this.ser = Math.floor(random(0, 2));
this.directions = [
[this.x - 1, this.y - 1],
[this.x , this.y - 1],
[this.x + 1, this.y - 1],
[this.x - 1, this.y ],
[this.x + 1, this.y ],
[this.x - 1, this.y + 1],
[this.x , this.y + 1],
[this.x + 1, this.y + 1]
];
}
yntrelVandak(ch, ch1, ch2, ch3, ch4) {
var found = [];
for (var i in this.directions) {
var x = this.directions[i][0];
var y = this.directions[i][1];
if (x >= 0 && x < matrix[0].length && y >= 0 && y < matrix.length){
if (matrix[y][x] == ch || matrix[y][x] == ch1 || matrix[y][x] == ch2 || matrix[y][x] == ch3 || matrix[y][x] == ch4) {
found.push(this.directions[i]);
}
}
}
return found;
}
}