-
Notifications
You must be signed in to change notification settings - Fork 1
/
tron.em
50 lines (41 loc) · 1.44 KB
/
tron.em
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
var cycles = [];
var cycleMesh = 'meerkat:///wmonroe4/lightcycle.dae/optimized/0/lightcycle.dae';
function entityScript(args) {
var referee;
onCycleCreated = function() {
referee = system.createVisible(args.referee);
{'tron':'cycleCreated'} >> referee >> [];
}
system.import('work/cycle.em');
}
function onCycleCreated(message, sender) {
system.print('cycle created!\n');
cycles.push(sender);
simulator._binding.addAction('tron.left', turnLeft);
simulator._binding.addAction('tron.right', turnRight);
simulator._binding.addAction('tron.start', start);
simulator._binding.addAction('tron.stop', stop);
simulator._binding.addBindings([
{ key: ['button-pressed', 'j'], action: 'tron.left' },
{ key: ['button-pressed', 'l'], action: 'tron.right' },
{ key: ['button-pressed', 'comma'], action: 'tron.stop' },
{ key: ['button-pressed', 'k'], action: 'tron.start' }
]);
// simulator._camera.follow(cycles[0]);
}
onCycleCreated << {'tron':'cycleCreated':};
system.createEntityScript(system.self.position,
entityScript, {'referee': system.self.toString()},
system.self.queryAngle, cycleMesh, 1);
function turnLeft() {
{ action: 'left' } >> cycles[0] >> [];
}
function turnRight() {
{ action: 'right' } >> cycles[0] >> [];
}
function start() {
{ action: 'start' } >> cycles[0] >> [];
}
function stop() {
{ action: 'stop' } >> cycles[0] >> [];
}