In recent years, online multiplayer has become a must-have feature for video games. Whether playing head-to-head or cooperatively with friends, or just seeing where your scores stack up on a global leaderboard, nearly all modern games have some kind of online connectivity built in.
How does online gaming work? What tools and programming languages are required to make it work? Find out by reading this article.
Online Functionality in Video Games
There are many different types of online features that video game designers can choose to build into their products. Each one requires different design priorities, programming, and backend services in order to work properly and enhance the gaming experience.
Game Leaderboards and High Scores
One of the most basic online features is an online scorekeeping and leaderboard system. This works well for single-player games that have a straightforward scoring system. Players’ high scores are posted on various leaderboards, often broken out by daily, weekly, monthly and all-time. This lets players see how they stack up against people playing the same game all over the world. In addition to leaderboards, many games use a system for keeping track of achievements over time. And some offer a system for challenging friends and comparing scores with individuals.
At its most basic, these systems only require some kind of database storage and a means for the game client to access the database. Adding additional features can add some complexity, like authentication. But because scores and leaders aren’t updated very often, this type of online video game connectivity requires little overhead and infrastructure.
A step up from a basic leaderboard is turn-based multiplayer. This works well for turn-based games such as board games, card games and strategy games like Civilization. Like with leaderboards, real-time communication between players isn’t required, though it does need to be fast enough to not cause a lot of lag when beginning or ending a turn.
Turn-based multiplayer games can require a bit more complexity. Typically, the state of each game is stored in a database, which is then sent to each player during the game. The backend also needs to make sure that each move submitted by the player is legal, to prevent cheating or corrupted data from interfering with the game. This is in addition to leaderboard and scorekeeping features that the game may also make use of.
In a real-time multiplayer game, the game needs to constantly update with the positions of all of the other players. This requires extremely efficient programming of both the game client and the backend to reduce lag and give players an optimal experience. Real-time multiplayer is common in action games like first-person shooters, as well as role-playing games like World of Warcraft and real-time strategy games like StarCraft.
In many real-time multiplayer games, game clients attempt to establish a direct connection with each other to reduce lag. In some games, this can be done manually, or the game publisher operates a matchmaking service that allows players to find other players and set up ad-hoc multiplayer games. In other cases, all connections run through separate server software that can be hosted by players, the game publisher, or third parties. The game publisher or others may publish lists of public servers for a particular game for users to choose from, or make them accessible directly from the game.
How Video Games Communicate
To make video games talk to each other, they require some kind of networking component built in to them. These can be built into game engines, built from scratch, or built using a third-party networking library.
Game Engine Networking
Some game engines feature some built-in networking features. Engines like Source and CryEngine include a networking stack designed for real-time multiplayer action games and FPSes that are commonly built on those platforms. Built-in game engine networking is usually sufficient for most games, but in some cases you’ll be able to get better performance by building it yourself or using a library.
Build Your Own Networking
Many game engines don’t include networking components, or they may not meet the needs of the game you’re designing. In that case, you’ll need to build and implement networking features yourself.
To build networking features, you’ll need to understand things like protocols (TCP vs. UDP), encryption, compression, and latency mitigation. Building networking into a game is complex, but is often the only way to obtain the features that your game needs. This can also involve building the server software that handles communication between the server and game clients.
Use a Third-Party Library
A third option for incorporating networking into a video game is to use a third-party networking library. These can either be standalone libraries that are intended for client-server or peer-to-peer game communications, or they can be bundled with a game platform service, such as Photon.
There are dozens of game-focused networking libraries available, so you’ll need to determine which one will meet the requirements of your game and will be compatible with your game engine and programming language.
Video Game Backend Components
Once your game is able to talk to the network, it will need something to talk to. That’s where video game backend and server software comes in. Depending on the multiplayer modes and features of the game, backend software can vary in complexity and the technologies used. Below are some examples of how backend software is used and developed for video games.
High Scores, Matchmaking, and Social Features
At its most basic, multiplayer backends for video games take the form of a simple web server accessible over a REST API. The video game makes REST calls to the server, and it responds with information that’s used to fill in and update high score tables, usernames, friend lists, and even head-to-head challenges.
Like any web server, there are many different options available to develop this part of the stack, depending on the features and performance needed. For many games making use of scalable cloud infrastructure, using a modern server software like Node.js gives good performance while keeping things simple.
Multiplayer Server Software
For games that use a server software to facilitate real-time multiplayer games, the server software needs to be lightweight and fast to reduce latency and give players the best possible experience. For this reason, most developers turn to the ever-popular C++ for video game server software. Server software also handles things like hit detection and lag compensation, to ensure that all connected players are experiencing the same game actions at the same time.
Some game engines and networking libraries include tools to build server software. For example, the Source engine includes tools to build and customize game servers for games built using its networking engine.
Cloud Servers for Video Games
For popular video games that draw millions of players, the backend software needs to be robust and scalable enough to handle the load without crashing and making the game unavailable to players. This is where cloud software comes in.
By running the video game server software in the cloud, the game publisher can access additional resources on demand. This can even out spikes in resource use that could take down a single server during heavy load.
To build cloud infrastructure for video games, standard cloud development practices can be used. This includes things like a microservice architecture and data storage using NoSQL components like Redis.
Alternatively, dedicated gaming cloud platforms can be used. Big players like Google (Firebase) and Amazon (GameSparks) as well as third-party services like Photon and PlayFab offer game-focused cloud game platforms and SDK integrations that can simplify the implementation of multiplayer for your video game.
Next Up: Packaging and Distributing Your Video Game
So far, we’ve covered selecting a programming language, using a video game engine, creating graphics and audio, and multiplayer features. In the next and final article of this series, we’ll look at how video games are finalized, packaged and distributed.