So the 2048 craze has pretty well taken hold, so I decided to make a little mod myself out of it. The idea is that every 10 seconds, everyone playing accept everyone else’s keystrokes for a brief moment. I did this using Socket.io along with Node.js to send movements across clients. The main bit of code on the server involves adding and removing the event listener the appropriate intervals:
1 2 3 4 5 6 7 8 9 10 |
|
I also added a display so you can know how many other players are online! You can check it out here.