Keys Of Triumph
The game is cross-platform and can be played by any modern browser which supports webgl 1 or more. It revolves around a fantasy world where 3 races exist. Basically the players are brought in a faction war where each faction earns points by invading others territories.
This whole project was a challenge. The main complexity was in writing the network code so that a persistent virtual world would be created. Afterwards, when we had it tackled, we had to come up with scalable architecture for the backend so that it would span multiple servers but still offer the persistent world to multiple clients. In the end, the game client had to be graphically pleasing yet it had to performant. Doing this in the browser was not easy. Here are some of the main challenges we have identified :
- Network for persistence across thousands of players
- Backend scalability to span multiple servers without ruining persistence
- Graphically pleasing but performant game client
- Making the game playable in 60 fps both in desktop and mobile environment
Make the game from the beginning multiplayer. It is easier to turn a multiplayer game into singleplayer than vice-versa
1. Network for persistence across thousands of players
The network was the part which we wanted to tackle first and to have it stable as soon as possible. It is not easy to get the network part of multiplayer games right so we put a big part of our focus into it. What we wanted was to create the right structures from the beginning in order to network different functionalities of the game in an easier way later on.
In fast-paced online multiplayer games, both client and server need to execute the same code, this way we ensure there is enough determinism to be able to create a persistent virtual world. We started with the server code first and then mirrored it in the client. The never ending problem to tackle in multiplayer games is to create an online gaming experience without cheaters, this means the server needs to be authoritative and the game client as thin as possible, every decision should be made server-side and this is what we did.
2. Backend scalability to span multiple servers without ruining persistence
There are quite a few not very easy architectural decisions to be made when designing online multiplayer games, especially if they should host thousands of players. We had to take into account spamming in the chat, the heavy database operations when logging in and out, the thousands of network requests sent back and forth from the server to the client and so on. We decided to divide the backend into 3 servers.
- Login server – Responsible for synchronizing the game servers and handle the database operations.
- Game server – The server where the game was emulated and then synchronized with the game clients.
- Chat server – The server responsible for handling the chat of the game.
For us every map was an instance of the Game server, the login server handled all the instance spawning through a mixture of ssh and socket communication. The game servers communicated with each-other and with the clients. By the end of the day we had a very pleasing result both in scalability and performance.
3. Graphically pleasing but performant game client
We needed the game to accessible from multiple devices, also from older ones. Add to it the fact that browser rendering is not the fastest there is and you have a pretty tough challenge to solve. What we did for this was implementing LOD ( Level of Detail ), octrees, our own frustrum culling for meshes not visible in the main camera, having a very tight poly budget and so on. We also added a few post-processing filters to aid to the look and feel of the game like bloom and fog.
3. Making the game playable in 60 fps both in desktop and mobile environment
We had used webgl2 for the browser rendering, we had to revert to webgl1 if the device was a mobile phone or tablet. Mobile does not support webgl2 yet it does support opengl es 3.0. For mobile we also had to reduce the post-processing filters as it impacted performance quite a bit.
Play from everywhere without downloading anything.
This solution aims to bring a 3D multiplayer gaming experience in the browser thus making it possible for people to play the game without the need of downloading anything.
Most of the games of this genre usually have gigabytes to download, by making it browser based, while it still has quite a few data to retrieve, it is in background and the experience is almost as if there is nothing downloading.
This is a game which you can play everywhere, be it in front of your pc. tablet or mobile, the user experience is very similar and this is the aim of the whole solution.
This application was developed in web technologies. BabylonJS was used for the client-side and the Game server. Socket.io was used for the socket connections, The backend run all on nodejs and PHP was used for the webservice which communicated with the Database. The Database was Mysql.