# Common mistakes when developing a game with Socket.io and Node.js

I am not a game developer by trade but am working on a card game (that is real time, not turn based). I was wondering what the common mistakes are that people make when new to this sort of development so that I can avoid them!

• Generally speaking, these kinds of questions don't do so well. From the faq: You should only ask practical, answerable questions based on actual problems that you face – Tetrad Jul 28 '11 at 20:19
• A common mistake is trying to avoid mistakes, don't do that, rather learn from your mistakes, its the base for your most precious resource, your experience – Maik Semder Jul 28 '11 at 20:47
• I also think this is far too specific a problem - the number of people who have completed games using such new technologies as Socket.io and Node.js are probably numbered between the 5 to 20 and I doubt they're all watching this website. – Kylotan Jul 28 '11 at 21:27
• @Kylotan, those kind of niche questions are actually good for the site. joelonsoftware.com/items/2010/04/19.html – Tetrad Jul 28 '11 at 23:31
• I wasn't suggesting this was a bad match for this site (apart from the vagueness and subjectivity already noted), but more that it's too soon to ask such a general problem about something that hardly anybody here uses. Joel's post implies very specific questions regarding general technologies, whereas this is (currently) a general problem regarding very specific technologies. I don't mind the question being here, but the OP will find more useful help elsewhere at this point. – Kylotan Jul 29 '11 at 18:04

There is a Google Techtalk featuring Rob Hawkes, creator of Rawkets, who talks about the problems he ran into while creating his game with Websockets and Node.js. He also comes up with some pretty slick solutions for the problems that he faced.

• It's a little high-level but overall seems good. I just skimmed through it. – Davy8 Aug 4 '11 at 11:40

The biggest mistake, is simply playing the games on the client side, and allowing them to communicate their information as they see it. Have the clients simply communicate their input, and render a model sent from the server at discrete intervals. (Store these models in an array with a server-timestamp, then interpolate between two known timestamps to render all actors everyframe)

I have created a framework specifically for creating HTML5 realtime multiplayer games, based on the Client/Server model. In this model, players send only input to the server (keys being pressed) - and the game occurs on the server.

The server sends timed world-snapshots to all clients, and clients render themselves say 75 ms back in time from the current time, by finding two known world updates their rendertime falls between.

Repository (contains 3 demos) https://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs

Video Box2D demo in action: http://vimeo.com/24149718

Slides from JSConf 2011: http://www.slideshare.net/MarioGonzalez15/realtime-html5-multiplayergameswithnodejs-7868336

It's based on Quakeworld and Valve's Source engine whitepapers: http://fabiensanglard.net/quakeSource/index.php http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

• Very nice ! Gonna mess around with it one of these days. – I.devries Aug 5 '11 at 13:28