Merge pull request #27 from jedwood/master
Add flips and acceleration toggle
Esse commit está contido em:
@@ -14,6 +14,10 @@ function pilot(name, deps) {
|
||||
console.log("calibrate", cmd);
|
||||
return deps.client.calibrate(cmd.device_num);
|
||||
});
|
||||
socket.on('/pilot/animate', function (cmd) {
|
||||
console.log("animate", cmd);
|
||||
return deps.client.animate(cmd.action, 500);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ PILOT_ACCELERATION = 0.04;
|
||||
, backward = 's'
|
||||
, left = 'a'
|
||||
, right = 'd'
|
||||
, flip = 'f'
|
||||
;
|
||||
if (options && options.keyboard === 'qwerty') { }
|
||||
else if (options && options.keyboard === 'azerty') {
|
||||
@@ -52,6 +53,10 @@ PILOT_ACCELERATION = 0.04;
|
||||
69 : {
|
||||
ev : 'drone',
|
||||
action : 'disableEmergency'
|
||||
},
|
||||
70 : {
|
||||
ev : 'animate',
|
||||
action : 'flip'
|
||||
}
|
||||
};
|
||||
Keymap[keyCodeMap[forward]] = {
|
||||
@@ -79,6 +84,7 @@ PILOT_ACCELERATION = 0.04;
|
||||
console.log("Loading Pilot plugin.");
|
||||
this.cockpit = cockpit;
|
||||
this.speed = 0;
|
||||
this.moving = false;
|
||||
this.keys = {};
|
||||
|
||||
// Start with magneto calibration disabled.
|
||||
@@ -127,6 +133,12 @@ PILOT_ACCELERATION = 0.04;
|
||||
*/
|
||||
Pilot.prototype.keyDown = function keyDown(ev) {
|
||||
console.log("Keydown: " + ev.keyCode);
|
||||
if (ev.keyCode == 9) {
|
||||
PILOT_ACCELERATION = (PILOT_ACCELERATION == 0.04) ? 0.64 : 0.04;
|
||||
console.log("PILOT_ACCELERATION: " + PILOT_ACCELERATION);
|
||||
ev.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (Keymap[ev.keyCode] == null) {
|
||||
return;
|
||||
}
|
||||
@@ -134,8 +146,30 @@ PILOT_ACCELERATION = 0.04;
|
||||
|
||||
var key = ev.keyCode;
|
||||
var cmd = Keymap[key];
|
||||
//if flip, determine which direction to flip
|
||||
var regFlip = /^flip/;
|
||||
if (regFlip.test(cmd.action)) {
|
||||
console.log("FLIP!");
|
||||
//check for which direction to flip
|
||||
switch (this.moving) {
|
||||
case 'front':
|
||||
cmd.action = 'flipAhead';
|
||||
break;
|
||||
case 'back':
|
||||
cmd.action = 'flipBehind';
|
||||
break;
|
||||
case 'right':
|
||||
cmd.action = 'flipRight';
|
||||
break;
|
||||
default:
|
||||
cmd.action = 'flipLeft';
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
// If a motion command, we just update the speed
|
||||
if (cmd.ev == "move") {
|
||||
this.moving = Keymap[ev.keyCode].action;
|
||||
if (typeof(this.keys[key])=='undefined' || this.keys[key]===null) {
|
||||
this.keys[key] = PILOT_ACCELERATION;
|
||||
}
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário