HTML and CSS Reference
In-Depth Information
socket.on("master",function() {
gameType = 'master';
Q.stageScene("game");
});
socket.on("slave",function() {
gameType = 'slave';
Q.stageScene("game");
});
socket.on("end",function() {
Q.clearStage(0);
});
socket.on('delay',function(data) {
if(data.steps == 3) {
// delay 1/2 of the round trip time
delay = (new Date().getTime() - data.timer)/2;
if(delay > 50) {
delay = 50;
}
} else {
data.steps += 1;
socket.emit('delay',data);
}
});
setInterval(function() {
socket.emit('delay',{ steps: 0, timer: new Date().getTime() });
},2000);
});
Figure 21-1 shows the final game played on two adjacent desktop browsers.
 
 
Search WWH ::




Custom Search