Permalink
Browse files

better fps, flip

  • Loading branch information...
1 parent daf48c0 commit 066f4268a2e29e0d9e469e498e3aaaeb1619aba1 @substack committed Oct 5, 2012
Showing with 12 additions and 7 deletions.
  1. +3 −1 browser/control.js
  2. +1 −1 lib/detect.js
  3. +8 −5 server.js
View
@@ -23,11 +23,13 @@ module.exports = function (client) {
shift_down: function (n) { ctrl.a(-1 * n) },
shift_t: function (n) {
- client.takeoff(1 * n)
client.disableEmergency()
+ client.takeoff(1 * n)
},
shift_l: function (n) { client.land(1 * n) },
+ f: function (n) { if (n) client.animate('flipAhead') },
+
}
window.addEventListener('keydown', function (ev) {
View
@@ -22,5 +22,5 @@ module.exports = function (w, h, buf) {
matches ++;
}
}
- return matches > 350;
+ return matches > 400;
};
View
@@ -50,19 +50,22 @@ png.on('error', function (err) {
console.error('caught error ' + err);
});
-var last = 0;
+var last = { frame : 0, detect : 0 };
var detected = false;
png.on('data', function (buf) {
- if (Date.now() - last < 1000) return;
- last = Date.now();
+ if (Date.now() - last.frame >= 100) {
+ emitter.emit('image', buf.toString('base64'));
+ last.frame = Date.now();
+ }
- emitter.emit('image', buf.toString('base64'));
+ if (Date.now() - last.detect < 1000) return;
+ last.detect = Date.now();
if (!redMode) return;
if (detected) return;
- if (detect(640, 360, buf)) {
+ if (detect(640 / 2, 360 / 2, buf)) {
detected = true;
emitter.emit('red');

0 comments on commit 066f426

Please sign in to comment.