-
Notifications
You must be signed in to change notification settings - Fork 0
/
wanderer.js
29 lines (23 loc) · 963 Bytes
/
wanderer.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
/* jshint worker: true, latedef: false */
/* global Neocortex */
/**
* Wanderer uses the Neocortex To manage a queue system for you, and predefines some actions to use.
*/
// Import cortex for helpers.
importScripts('/scripts/brains/neocortex.js');
// Wrapping neocortex creating in a function allows it to be called recursively, so the robot
// performs these actions in a loop.
function addActions() {
var neocortex = new Neocortex(self);
neocortex.addMove('moveTo', { x: 100, y: 100 });
neocortex.addMove('fireAtClosestEnemy');
neocortex.addMove('moveTo', { x: 500, y: 100 });
neocortex.addMove('fireAtClosestEnemy');
neocortex.addMove('moveTo', { x: 500, y: 500 });
neocortex.addMove('fireAtClosestEnemy');
neocortex.addMove('moveTo', { x: 100, y: 500 });
neocortex.addMove('fireAtClosestEnemy');
neocortex.start(addActions);
}
// The callback to start is a function you want to run when the queue has been exhausted
addActions();