Last week we released our special Christmas game Snowballs. Every year we try to create something fun in a minimum amount of time. This year we limited ourselves to two evenings of work, in which we transformed our earlier created supersnak.es game into a simple snowball throwing game. A frequently asked question we got from you is how it's all made. In this post I will explain how the magic works. Please note that this is not a walkthrough, but more of an insight.
From this point on, it's possible to connect with the game. So let's take a look at the controller. When you open it up on your phone and enter the code you see on your computer, a WebSocket connection is being made, just like we did before on your computer. This time we request the node.js server to add us to the room with the code we have. The server tells us whether or not this room exists, after which you enter your name, and your controller is added to the room.
And that's it! Using this technique, all commands from join 'till disconnect can be passed through, and the game logic is doing the rest. Now of course a lot of things could be further improved in our game. For example, instead of using our own supersnak.es code, we could probably better use some existing game framework. However, it's just a fun side-project, done in two evenings work. So I think we shouldn't be too critical in this case.
I hope this clears things up a little bit but feel free to drop your questions in the comments below.