-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAI.js
62 lines (62 loc) · 1.29 KB
/
AI.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
function ai(){
if(pillar1.y > pillar2.y & pillar1.y > pillar3.y){
if(box.x>(pillar1.height+gapWidth/2)+20){
aiKeyRight = 0;
aiKeyLeft = 1;
}
else if(box.x<(pillar1.height+gapWidth/2)-20){
aiKeyLeft = 0;
aiKeyRight = 1;
}
else{
aiKeyLeft = 0;
aiKeyRight = 0;
}
if(box.x>pillar1.height & box.x<pillar1.height+gapWidth){
aiKeyUp = 1;
}
else{
aiKeyUp =0;
}
}
else if(pillar2.y > pillar1.y & pillar2.y > pillar3.y){
if(box.x>(pillar2.height+gapWidth/2)+20){
aiKeyRight = 0;
aiKeyLeft = 1;
}
else if(box.x<(pillar2.height+gapWidth/2)-20){
aiKeyLeft = 0;
aiKeyRight = 1;
}
else{
aiKeyLeft = 0;
aiKeyRight = 0;
}
if(box.x>pillar2.height & box.x<pillar2.height+gapWidth){
aiKeyUp = 1;
}
else{
aiKeyUp =0;
}
}
else if(pillar3.y > pillar1.y & pillar3.y > pillar2.y){
if(box.x>(pillar3.height+gapWidth/2)+20){
aiKeyRight = 0;
aiKeyLeft = 1;
}
else if(box.x<(pillar3.height+gapWidth/2)-20){
aiKeyLeft = 0;
aiKeyRight = 1;
}
else{
aiKeyLeft = 0;
aiKeyRight = 0;
}
if(box.x>pillar3.height & box.x<pillar3.height+gapWidth){
aiKeyUp = 1;
}
else{
aiKeyUp =0;
}
}
}