-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlauncher-cli.js
57 lines (51 loc) · 1.1 KB
/
launcher-cli.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
var rocketlauncher = require('./launcher');
launcher = new rocketlauncher.RocketLauncher();
var stdin = process.openStdin();
require('process').stdin.setRawMode(true);
var queued_command = '';
stdin.on('keypress', function(chunk, key) {
console.log(key);
console.log(chunk);
if(key && key.ctrl && key.name == 'c')
{
launcher.quit();
}
else if(key && key.name == 'j')
{
launcher.up();
}
else if(key && key.name == 'k')
{
launcher.down();
}
else if(key && key.name == 'h')
{
launcher.left();
}
else if(key && key.name == 'l')
{
launcher.right();
}
else if(key && key.name == 'g')
{
launcher.shoot();
}
else if(key && key.name == 'f')
{
launcher.stop();
}
else if(key && key.name == 'd')
{
launcher.boom();
}
else if(key && key.name == "enter")
{
launcher.runCommand(queued_command);
queued_command = "";
}
else
{
queued_command = queued_command + chunk;
console.log("Queued command is: " + queued_command + "\n");
}
});