aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHolden Rohrer <holden.rohrer@gmail.com>2019-12-18 23:07:53 -0500
committerHolden Rohrer <holden.rohrer@gmail.com>2019-12-18 23:07:53 -0500
commitbad2bd5bd1c26e33a902b03ff4670aaa5e9fdc1d (patch)
tree02849980557d9419bde096f4fa1a3bd7c012845f /examples
parenta8e1bb2c12467b358422d53f4bb0563dae01fb96 (diff)
jarvis work
Diffstat (limited to 'examples')
-rw-r--r--examples/jarvis.js26
1 files changed, 10 insertions, 16 deletions
diff --git a/examples/jarvis.js b/examples/jarvis.js
index 19f9651..f31a9ea 100644
--- a/examples/jarvis.js
+++ b/examples/jarvis.js
@@ -3,20 +3,10 @@
const Space = require('../space');
const Socket = require('../socket');
const getdims = require('../utils/getdims');
+const tilekeys = require('../utils/tilekeys');
var main = new Socket();
-
-function Sparse(){ // A "sparse" data-storage mechanism
- this.data = [];
- this.avail = [];
- this.add = function(data){
-
- }
- this.del = function(id){
- this.avail.push(id);
- this.data[id] = null;
- }
-}
+var read = {};
function equals(arg1,arg2){ // Just takes the specific case argument of each being an int pair
return arg1[0] == arg2[0] && arg1[1] == arg2[1]
@@ -25,19 +15,23 @@ function equals(arg1,arg2){ // Just takes the specific case argument of each bei
main.on('open', ()=>{ // Tries to identify itself with a cursor movement
let coords = [Math.floor(Math.random()*100000+16),Math.floor(Math.random()*100000+16)];
main.cursor(coords);
- main.on('cursor', detect);
+ main.on('cursor',detect);
function detect(pos, send){
if (equals(pos[0],coords)){
main.off('cursor', detect);
- this.emit('identity', sender);
+ this.emit('identity', send);
}
}
})
main.on('identity', (sender) => {
+ console.log('identity activated');
main.on('tileUpdate', (send, source, tiles) => {
if (send == sender) return;
- // Get dimensions somehow
-
+ let dim = tilekeys(tiles);
+ let data = new Space(); data.fromfetch(tiles, [dim[0][0],dim[0][1],dim[0][0],dim[0][1]],conform=false);
+ console.log(data.print());
+ //let data = new Space(); data.fromfetch(tiles, dim);
+ //data.search
})
})