Skip to content
Browse files

works until the player moves out of the initial chunk. seems they are…

…n't getting enrolled in the new chunk
  • Loading branch information...
1 parent 07bac6b commit 0c9fcd4efd90afd44cb93d5b97bced2b7bd82ec2 @jessehattabaugh committed Aug 1, 2012
Showing with 9 additions and 10 deletions.
  1. +6 −9 public/client.js
  2. +3 −1 server.js
View
15 public/client.js
@@ -4,9 +4,6 @@
(function(){
- // closure for callbacks
- var self = this;
-
var plid = null;
var password = null;
@@ -55,7 +52,7 @@
socket.on('welcome', function (pos) {
console.log("login successfull");
- console.dir(pos);
+ //console.dir(pos);
x = pos[0];
y = pos[1];
enrollment();
@@ -65,11 +62,11 @@
socket.on('enrolled', function(data){
console.log("you enrolled in chunk "+data.chuId);
//console.dir(data);
- self.chunks[data.chuId] = {};
+ chunks[data.chuId] = {};
//todo: retrieve chunk pixel data from db and draw to a canvas
});
- // todo: this.socket.on('unenrolled')
+ // todo: socket.on('unenrolled')
var moving = false; // whether or not we are in the process of moving
@@ -107,11 +104,11 @@
socket.on('movement', function(data){
- console.log(plid);
+ //console.dir(data);
if(data.plid == plid){
console.log("you moved");
- x = to[0];
- y = to[1];
+ x = data.to_x;
+ y = data.to_y;
moving = false;
enrollment(); // todo: only call this when crossing a chunk boundary
} else {
View
4 server.js
@@ -12,7 +12,7 @@ app.get('/', function(req, res) {
res.sendfile('index.html');
});
-PORT = process.env.PORT || 5000;
+PORT = process.env.PORT || 5050;
app.listen(PORT);
console.log("Server started on port " + PORT);
@@ -76,6 +76,8 @@ io.sockets.on('connection', function(socket) {
console.dir(data);
var chuId = data.chuId;
if(!(chuId in subClients)){
+ console.log('creating a subClient for '+chuId);
+ console.dir(subClients);
var chunkClient = redis.createClient();
chunkClient.on('message', function(chan, msg){
console.log("chunk("+chan+") recieved a message");

0 comments on commit 0c9fcd4

Please sign in to comment.
Something went wrong with that request. Please try again.