The TileGame is an experimental 2D online game chatroom, written with Golang and Javascript, where you can chat with anybody who goes to the same webpage in their browser. Everybody has a cat character, and can easily type in their chat message, which will appear above your character, and is visible to everybody else who is also online!
Characters chatting in the TileGame
I wrote this primarily for educational purposes. My goals were to learn about computer networking in general, and more specifically how to write and run servers. I also wanted to learn how to design APIs that can be accessed by a client that is written using different tools or languages than the server, to allow for different clients (including automated bot clients) to be built.
In the beginning, I wrote a chatroom server in Go using websockets, that simply broadcast all of the messages to everybody else in the room. I wrote a simple interface in Javascript to interact with the server.
I realized that the concept of a chatroom could extend to character movements and locations. So, I created a grid of locations, and added some mechanisms for the server to move characters. The client clicks a desired location, and this sends a message to the server. The server updates character locations based on those destinations, and broadcasts its state to everybody in the room.
Blue Square: Client Request
Red Square: Server State
As I was building the game, I wanted to see what the network connection and speed under different conditions. To achieve this, I built a small tool that sent a burst of websocket packets to the server, which echoed them back to the client. I could use this measure the round trip time of the packets, and graph them to see what was happening.
Round Trip Time (RTT) of packets from mobile devices
Finally, I added some cat images to act as the characters, and made the text from the chatroom appear over the players head! I had a lot of fun creating this project, and I learned tons about networking, hosting on cloud servers, and lessons in programming in general!
There are several future projects and experiments that working on the Tilegame has encouraged me to try.
-
I want to make a 3D game server, with more complicated movement features. One of the things I learned during this project is that using TCP (upon which websockets is built) can be limiting for real-time games, so in the future I would like to experiment with UDP.
-
The "round trip time" tool I made was very rudimentary, and didn't paint a full picture of what was happening. Making tools to test the network connections of clients can provide a lot of useful information, so in the future I want to improve in this area.
-
This game didn't have user accounts or a database, so in the future I want to have account management features, logins, and persistent storage, so that I can build more interesting features.