Creating my first simple online game
snake online browser game
So, second blog post, uh. I don’t know why am I doing this.
if you just want to play the game, go here: Snake Online Minigame
if you want to check out the game’s code: github repository
I will be writting about the second game I’ve ever made, Snake Online, a multiplayer online server based game.
Why Make a Multiplayer Game?
It was my second game, I don’t know if it’s a good idea to go straight to a multiplayer game, but I did anyway. I was bored of the idea of making offline singleplayer games and making something that I could play with my friends drove me up.
How It Works?
When I was researching on how to make a online game I read so many articles, there was a lot I had to handle, player input, server, latency. Looked really complicated. But I will try explaining how this snake online game works.
I used a Client-Server architecture (or I think I did). There is a main server which process all the game data and send updates to the clients every x miliseconds, the clients just get the data from the server and render it for the player, oh, the client also handles player input and send it to the server.
So, this was the watered down explanation, I guess snake was a little bit simpler because of the server ticks (updates every x time) and I didn’t need to handle latency (also didn’t know how to)
Latency Really Matters
One thing I found out while making this game is that latency makes a huge difference if your game does not do anything to compensate it. I initially hosted the game on a free Heroku Server, which was in NA, but since I am from Brazil, the game was frustrating to play, almost unplayable. When I changed to a South America server using Amazon EC2 service the game ran smoothly and was actually fun to play.
The End Result
Well, I actually had a good time making this game and understood a little bit how complicated online games are. Oh, and the 5 minute play time I had with my friends was also worth it, snake gets really frustrating with 3+ people after a while, but it’s fun.
That’s it for today, thanks for reaching this far, I guess you are the only one.