Issue
I am creating a multiplayer Online quiz game in Android Studio using Java. I am having players registered using Firebase in my app. Ok so the main thing is , I'm having different set of quiz tournaments like 10 players tournament, 20 player tournament ,30,40 etc., All tournaments are running one at a time.... For example Consider a 20 players tournament is about to begin, So 20 different players compete all together at a time and then rank is generated of those 20 players to calculate winning of those players (Rank is generated on the fact who clicked the answer button fastest).
I just want to know synopsis of how can I implement multiplayer in my app. Most importantly i want to know how can i make the 20 players to play at a time and in a particular tournament.
Solution
One of the first things you need to consider is how do you manage state for each game instance. What is a tournament? Do players play singleplayer, record their results, and whoever has the highest score wins the "tournament"? Do 20 players all compete at the same time in the same game?
The most common approach to synchronize game state in a particular instance is through a socket connection. What you would need to do is have a "match-making" server and a "game server".
The game server hosts a game and allows users to connect to it to be able to participate in the game. The match making server is what players connect to first. It is responsible for pooling players together in a "lobby" to start a new game (e.g. a player connects to the match-making server, the match-making server looks at the list of game servers that have not started yet and is not full and directs the player to that game server).
If you're gonna take this approach you would have to learn how to work with sockets.
Another option you can do is utilize Firebase realtime database. You would essentially store the same information. You query the database for available rooms, then set the player's database info to reflect the room that they were placed in.
Answered By - codecustard
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.