this is my client: http://pastebin.com/C9PHzTQg
this is my server: http://pastebin.com/j2dfL84d
Now is “multiplayer” rect’s, but how to do movement?
I am send to ‘b’ – “UP”, “LEFT”, “RIGHT”, “DOWN” and how to handle ant move player?
Sorry for my bad english language.
First, you need to learn prototypical inheritance! As it is, each
Playerwill have it’s own copy of thedrawmethod, so putdrawonPlayer.prototypeinstead:Then, I suggest you add a
movemethod toPlayer:Then, in your message handler, you just have to:
In the server, you would
emit('b', { player: playerId, direction: "UP" }, for example.Update: Instead of
drawinsidesocket.on('b', ...above, you could have something like:To redraw every 100 ms. It depends on the type of game, I guess.