Slithering Together: Making slither.io a Multiplayer Experience

Kainar Kamalov
HackerNoon.com
Published in
3 min readDec 22, 2016

--

As an engineering team at B12, we spend a lot of time building products powered by automation and the future of work. We also spend a lot of time hanging out and procrastinating — that’s how we found slither.io. To take a quick break from work we would often get in a game or two throughout the day. We noted that most of the time we were put into separate game rooms and although the game was a lot of fun, we wanted to slither together.

We began digging through the source to see if there was anyway to modify the code to put us in the same room and stumbled upon this line:

ws = new WebSocket(“ws://” + bso.ip + “:” + bso.po + “/slither”);

In Safari, you can modify debugger breakpoints to execute javascript, so we dropped a line in below the websocket creation to hardcode the ip and the port. We now had a way to always share game rooms. This worked for a while, however, we wanted to work together to beat other players and quickly found it was really hard to coordinate our locations. Enter the shared minimap.

Shared minimap.

Internally, Slither shares gameplay information across a websocket and builds a minimap locally of the user’s location. Since we can execute our own javascript, we can also access this location information and share it with other players we want to play with. We setup a simple websocket server to pass JSON encoded messages between players and by copying some of the game source code, we added our friend’s locations to the map. Since we were already sharing information, we also thought it would be nice to have a shared leaderboard between the players.

Shared leaderboard.

With these three features: shared game room, minimaps, and team leaderboard, we realized we had built a v1 of a multiplayer experience for slither.io. We wanted to publish and share with others so they could make teams of their own. We would love to see others contribute improvements! Send us some love on github.

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMI family. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.

If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!

--

--