Multiplayer implementation

There was a time when multiplayer was limited to conventional PC and console gaming. The modern day gaming industry consists of extensive use of social networking. This automatically opens up the opportunity for multiplayer gaming.

Improved hardware systems and continuous network support with modern connectivity have enhanced the world of multiplayer gaming. Multiplayer gaming can be classified mainly into two categories:

  • Real-time multiplayer
  • Turn-based multiplayer

Real-time multiplayer

Real-time multiplayer is just like playing sports together, where every player reacts to any action by the game or other players at the same time. For example, a football game is played by 22 players, and each and every player acts as per the situation at the same time. If we imagine the same scenario from a digital gaming perspective, it will be called a real-time multiplayer.

In the general structure of multiplayer games, there should be a server where the gameplay runs with all the logics and calculations. The server interacts with the database when required, and the user does not have any control.

The client or terminal devices are the only medium that interacts with users. However, in many cases there are some extra layers used on the client side to perform a few actions without server validation to keep the spontaneity of the real-time multiplayer game.

Let's look at the general architecture of the real-time multiplayer system:

Real-time multiplayer

The best practice to implement real-time multiplayer is to introduce the sync layer on each terminal application layer. This layer acts as a medium between the terminal device application and server.

Turn-based multiplayer

Turn-based multiplayer is a system where only one player gets the chance to play at a time. For example, in the game of chess, when a player plays their turn, the other player remains idle.

Generally, a turn-based multiplayer system is also controlled by a server. A server can be one of the clients itself. However, the execution layers work as shown in the following diagram. Many times, a database is also an optional part of the architecture. The server is responsible for activating UI control on particular terminal devices and should only listen to that device. Let's have a look at the architecture diagram:

Turn-based multiplayer

There are more types of multiplayer models possible in Android gaming. Until now, we have discussed only the models implemented over the Internet. Local multiplayer gaming is also possible in Android. We can classify these games into the following categories:

  • Single-screen real-time multiplayer
  • Pass and play turn-based multiplayer
  • Local network multiplayer

Single-screen real-time multiplayer

This kind of multiplayer game is dependent on the hardware features, other configurations, and feasibility. The device must support multiple inputs at a single point of time to support real-time multiplayer. For Android touch devices, it is recommended that the developers target large-screen devices to provide more space for control for multiple players at a time.

Pass and play turn-based multiplayer

This is a type of single-screen turn-based multiplayer model. In this model, all the participants should manage the play order manually among themselves to synchronize with the game turn.

Here, one player passes the same device to the next player after playing their turn. Then, the next player reacts to the current state of the game. In this model, the game state does not change until the completion of each turn.

In both single-screen multiplayer models, no network connectivity is required, and the database is an optional component that can be stored within the device memory.

Local network multiplayer

Both real-time and turn-based multiplayer models can be implemented using local network connectivity. In this case, one of the participating devices must act as a server and control the gameplay over local network connectivity using Bluetooth, Wi-Fi, or an infrared connection.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.7.240