-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path2.js
More file actions
31 lines (28 loc) · 702 Bytes
/
2.js
File metadata and controls
31 lines (28 loc) · 702 Bytes
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
/*
* Some times it helps to retain some state, state like "did I just come from
* back there?" You can keep any data you wish to preserve across events
* in the closure created by the initial execution of your code.
*
* For example:
*
* var beenThere = false;
*
* this.on('sensor:left', function() {
* beenThere = true;
* });
*
* this.on('sensor:right', function() {
* if (beenThere) {
* // already been left
* }
* });
*/
/**
* Tactic: Move right until you hit the wall, then head upwards and out.
*/
this.on("start", function(){
this.thrusters.left(true);
});
this.on("sensor:right", function(contact){
this.thrusters.bottom(true);
});