-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path5.js
37 lines (31 loc) · 821 Bytes
/
5.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
/*
* No explanation.
*/
/**
* Tactic: Where you are coming from and where you are headed to
* is the same each time you hit a wall, just stop the movement where
* you came from, and start off in the direction you're going.
*/
this.on("start", function(){
this.thrusters.top(true);
});
this.on("sensor:bottom", function(contact){
if (!contact) return;
this.thrusters.top(false);
this.thrusters.left(true);
});
this.on("sensor:right", function(contact){
if (!contact) return;
this.thrusters.left(false);
this.thrusters.bottom(true);
});
this.on("sensor:top", function(contact){
if (!contact) return;
this.thrusters.bottom(false);
this.thrusters.right(true);
});
this.on("sensor:left", function(contact){
if (!contact) return;
this.thrusters.right(false);
this.thrusters.top(true);
});