Create multiplayer experiences
There's nothing quite as thrilling as a multiplayer game. Learn how you can make the most our multiplayer games.
Types of games
Not all Gamezop games support multiplayer experiences. Here is a list of our games on which you can create real-time multiplayer experiences for your users.
There are 2 types of multiplayer games:
Sync
Games that are inherently multiplayer, such as Chess, Pool, Ludo etc. These games are designed to be played by more than 1 player where all players play together in a common arena / board.
Async
Games that are single-player in nature. For instance, a Fruit Slice game is a single-player game.
Generating game links for multiplayer games
When you open any game url
that you receive on our All Games API, the game opens a single-player experience by default.
To enable a multiplayer experience, you need to follow these steps:
Generate a roomDetails
object
roomDetails
objectThis carries all the details we need to create a match between your users. roomDetails
is a JSON object with the following values:
roomId
(Mandatory)
This is a free-form string that you must pass. Only players with the same roomId
are matched together. Examples:
If you are operating a casual games site, you can open a game with the same
roomId
for all users, increasing the liquidity pool.If you have a chat app and you want 2 players in a chat or a few players in a group to be matched with one other, you may have a unique
roomId
for each chat group.If you are a skill-gaming platform, you may want to have the
roomId
based on the entry-fee or skill-level, or a mix of both.
user
A JSON object with details of the user for who you are opening the game. In some games such as Pool, Chess etc., passing this value allows us to populate the profile picture / name within the game's UI as well. If you do not pass these values, our system will use some generic names and photos when the game is opened. The user
object must contain:
name
: Name of the usersub
: A unique identifier for the userphoto
: A URL for the user's profile photo
maxPlayers
The maximum number of players you want us to group into a single match. In case of some games like Chess, even if you pass maxPlayers
as more than 2, the system will only group 2 players into a match as Chess can't be played by more than 2 players.
However, in case of single-player games, we can group together up to 5 players in a room. While everyone will play the single-player game, they will all be able to see, in real-time, the current scores of the other players in the same match.
The maximum acceptable value is 5. If you pass a bigger number, the system will keep it as 5. If you don't pass any value, this will generally be 2 or 5 depending on the game.
minPlayers
The minimum number of players needed for a match to start. Generally, we recommend keeping this as 2. However, if you have a use-case where you only want to start a game if at least say 3 players join, you can use this value to do so. In case of a game like Ludo, you may want to only have 4 player matches, so you can keep the minPlayers
value as 4.
Once again, please note that this value will not hold in case of all games. If you pass minPlayers
as 4 in a Chess game, the system will still group only 2 players per game. If you don't pass any value, this will default to 2.
maxWait
The maximum amount of time (in seconds) for which the matchmaking process should go on. If minPlayers
are not found within that time, the matchmaking will stop and the user will be shown a screen that says no match was found. The user will be given an option to retry finding a match.
Defaults to 60 if you don't pass any value. Maximum acceptable value is 600. Minimum acceptable value is 5.
rounds
The number of attempts you want the users to have in the match.
This is also game dependent. In a game like Chess, we would only allow a maximum of 1 round per match. However, in the case of single-player games, you may want to allow the user to play up to 3 times to make a high score. In that case, you can pass rounds
as 3. For deciding the winner of the match, our system considers the best score of each player in the match from across all their rounds.
Defaults to 1 if you don't pass any value. Maximum acceptable value is 5.
cta
Client callback method name (Android/iOS JS bridge name and method).
This is the method name which Gamezop will call on client to send events related to match.
text
Text you want to show on bottom button on match over / no match found cases.
This key accepts only these values empty string ""
, go_home
or play_again
Defaults to go_home
if you don't pass any value.
allowBots
gameConfig
Base64 encode the object
Let's assume this is the final roomDetails
object you've generated and you now want to encode it:
If you're using Javascript, store this in a const
named roomDetails
, and then run:
You'll get the following value:
Create the multiplayer game url
url
If you are going to send user details or a wide variety of roomId
values, you may need to generate the final game link on the client instead of the server. If you aren't using those values, then you can manually generate a link and send all your users to the same link and they will keep getting matched with one other.
Generating the link is extremly simple. Once you have the encoded roomDetails
value, just append it to the URL you receive from the All Games API. The final URL will be of the following structure:
{url-from-All-Games-API} ?roomDetails= {encoded-object}
Get multiple users to open the multiplayer game together
Once you've set up the system to generate these links, you need to have multiple users from your platform open the links together. When a user opens one of these links, our matchmaking module tries to find other users from your Property ID with the same roomId
, and matches the users together in a multiplayer experience.
Receive data on match winners
In case you want a callback with details of the winners at the end of each match, you will have to provide 2 APIs for it. Detailed here.
Last updated