I spent a fair amount of time today showing off some technologies to other folks: Julia and I went over some of my past Flixel and Box2D games, and Lyndsey and I investigated various methods of casting on. (The latter is knitting, not code, of course.)
I also put together a working demonstration of communication both to and from the server using WebSocket, with help from Julia and Kate. I continue to be unimpressed by the Socket.io docs, which seem to be designed to make the user feel inept.
And here’s the client side (after initializing the canvas and setting default variable values and such):
123456789101112131415161718
functiondraw(){ctx.clearRect(0,0,canvas.width,canvas.height);ctx.fillStyle="ff0000";ctx.fillRect(otherMouseX-5,otherMouseY-5,10,10);}functionmouseMoved(e){//e is the event handed to usmouseX=e.pageX-canvas.offsetLeft;mouseY=e.pageY-canvas.offsetTop;ws.emit("mouseMoved",mouseX,mouseY)}varws=io.connect('http://localhost:5000/')ws.on('mouseMoved',function(mouseX,mouseY){otherMouseX=mouseX;otherMouseY=mouseY;})
The result is magically linked canvases: move around in one window, and the square cursor in the other window moves to follow.