Hello , I want to make a multiplayer game but i do not know how can someone tell me how to make multiplayer game
@braagamer82nw, Welcome to Thunkable community,
@braagamer82nw, i have made many realtime multiplayer basic games in thunkable using firebase like quiz game, racing game, ludo etc, but can u please tell which type of game do you want to make, like i have seen, in today’s time, when it comes to multiplayer game, most people say about fighting game, shooting games, or any other games, can u please tell, which game do you want to make and share some more information about it.
@ak_coder I want to make a game about that 2 teams enter a challenge each team has 5 or less players and when they enter the same game I want to make all of them see the challenge and try to do it in the real life and when someone lose he can press on his photo to discard himself from the challenge or discard other one but only in case of that the other player lost the challenge due to someone so that one will take the kill because the other player failed in the challenge and the team the all of his players lost the challenge the other team wins so I want when somebody become out all mobiles receive notification or a red cross on the photo of the player and play a mini video for the loser and the winner team in the end of game and output on the screen the one who has the most kills to take points more than the other winning members if you want more specific details I can tell you
@braagamer82nw, i am assuming that you have a better knowledge of firebase and variables and many other concepts like: logic building, functions, loops etc, because these are must for this game.
One most important condition: You must use the non drag & drop version of thunkable, because it provides better flexibility for this task.
I am also assuming that all players in your game must have a unique id, name, or anything, because this will make your game faster.
Also, you have to store the details of the player in firebase DB, like their name, id, password for the game, progress, points, match played etc.
Ok, so the first step is to you have to design that page where players will wait for opponents, you can add 10 images 5 at upper and a
vs image to x team versus y team, so when a user comes to that screen, you have to do this:
→ In your blocks add a variable called -
is waiting to true, so that you can whether this player is waiting or not, [Note: Make this value false when the user not playing]
→ Make an array in your firebase like make an array of
Waiting and add a unique user id/ name of that user in that array.
→ there might be a chance that someone else has already come to that screen and waiting for other players from his device, in that case, you have to add the name of user at the last of the array.
Now after adding the user, you have to do this:
→ add the
Realtime DB invisible component, now add when DB changed block and add a condition:
If (app variable is waiting) = true:
there are two possibities:
first, the user’s name is deleted from that waiting array and added to new array of objects
Playing in firebase.
Second, it is not deleted
So, you have to first check,whether the name of user is in the array or not, if not, then this means user is now in playing object, and is now playing the match and his name will also be in another array of object -
Current match, you have find his name in the playing object and get the match id, and if its present, then you have to check if the number of players including that user also in the waiting array is greater than or equal to 10, if they are greater than or equal to 10, this means now you have to take the first 10 elements of array, make a local vaiable for them, delete their names from waiting area, and add all the 10 names to another object of
playing, and the values of all the names, as its an object, will be unique random match id, and also you have to add the 10 names to
Current match array of object.
First do all these things and then tell the progress rate, and if any issue, then please tell, and also don’t forget to share the link of your app, so that i can also know how you are doing.
@ak_coder I understand all you said and I can do it but the only thing that I was asking about how to make firebase DB because I do not know anything about it and also how to create and use it and how to make all players in same room this is my main problem and sure i will send you to it to try it and give me your feedback but it will be in arabic and thanks so much for your help
@braagamer82nw, its very easy to setup firbase: please read here, Realtime DB by Firebase - Thunkable Docs
And, yes obviously, by using the method and process that i will, u can make all 10 players in a same room.
Just do the steps i told earlier, and tell your progress, because telling all things at one time will make you confused and you will then make mistakes, so please do all things one by one.
To know more about firebase: What is Google Firebase?
Ok thank you so so much for your help and I have made a big part of the game like the home screen inputting the name and picture and the only thing is left to make players in one room so I will do your steps and sure I will send you the game to try it again thanks you so much
@ak_coder I have one more question when I save things in realtime firebase from the thunkable live test it saves but when i downloaded the apk file for the app and try to save the things from mobile it does not save in realtime database