Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Cloud Data Help
- Thinktdm
- Scratcher
79 posts
Cloud Data Help
How to I make a Multiplayer game?
SCRATCH TIPS!
Visit https://scratch.mit.edu/studios/30434911/ for a huge library of free custom blocks and neat scripts.
—————————————————————————————————————————————-
when green flag clicked
if <(Old Custom Blocks) = [yes]> then
play sound [Celebration v]
add [custom blocks] to [project v]
else
think [cry] for (90) secs
add [custom blocks] to [project anyway v]
end
- maximcaux
- Scratcher
37 posts
Cloud Data Help
Simplest way to do it for 2 players:
Make seven variables. Make all of them except for player ID CLOUD variables by pressing the ‘cloud data: stored on server’ checkmark.
set cloud check to one. When someone tries to run the program and he can read the cloud variable, that means he is connected to the cloud. He will not be if he is on the offline editor, or a new scratcher. In the first instance we check if it is set to one, then we tell him he is connected. If it is zero, the default variable value, the game will tell him that he is not connected or is a new scratcher.
In player1:
Do nearly the same script in your second player. Here is what it should look like:
When the broadcasts are broadcasted, a sprite should tell the player the message of the broadcast.
For the rest of this to see if a player has left or not, go to the scratch wiki: https://wiki.scratch.mit.edu/wiki/How_to_Make_a_Multiplayer_Game
Here nearly everything is done the same way. Use the player 1 and 2 checks and the local ones to check if a player has left or not. You could also just do the whole tutorial from there than from here if you want.
Make seven variables. Make all of them except for player ID CLOUD variables by pressing the ‘cloud data: stored on server’ checkmark.
(cloud check)
(xp1)
(yp1)
(xp2)
(yp2)
(amountOfPlayers)
(player ID)
set cloud check to one. When someone tries to run the program and he can read the cloud variable, that means he is connected to the cloud. He will not be if he is on the offline editor, or a new scratcher. In the first instance we check if it is set to one, then we tell him he is connected. If it is zero, the default variable value, the game will tell him that he is not connected or is a new scratcher.
In player1:
when green flag clicked
forever
if <[cloud check] = [1 ]> then
if <[player ID] = [1 ]> then
go to x: (xp1) y: (yp1)
end
end
end
when green flag clicked
if <[cloud check] = [ 1]> then
if <[amountOfPlayers] = [ 0]> then
set [player ID v] to [player 1 ]
change [amountOfPlayers v] by (1)
broadcast [connected v]
forever
if <key [left arrow v] pressed?> then
change [xp1 v] by (5)
end
if <key [right arrow v] pressed?> then
change [xp1 v] by (-5)
end
if <key [up arrow v] pressed?> then
change [yp1 v] by (5)
end
if <key [down arrow v] pressed?> then
change [yp1 v] by (-5)
end
end
end
end
when green flag clicked
if <[cloud check] = [ 1]> then
if <[amountOfPlayers] = [ 2]> then
broadcast [sorry, the server is full! v]
end
end
when green flag clicked
if <[cloud check] = [0]> then
broadcast [sorry, not connected! v]
end
Do nearly the same script in your second player. Here is what it should look like:
when green flag clicked
forever
if <[cloud check] = [1 ]> then
if <[player ID] = [2 ]> then
go to x: (xp2) y: (yp2)
end
end
end
when green flag clicked
if <[cloud check] = [ 1]> then
if <[amountOfPlayers] = [ 1]> then
set [player ID v] to [player 2 ]
change [amountOfPlayers v] by (1)
broadcast [connected v]
forever
if <key [left arrow v] pressed?> then
change [xp2 v] by (5)
end
if <key [right arrow v] pressed?> then
change [xp2 v] by (-5)
end
if <key [up arrow v] pressed?> then
change [yp2 v] by (5)
end
if <key [down arrow v] pressed?> then
change [yp2 v] by (-5)
end
end
end
end
When the broadcasts are broadcasted, a sprite should tell the player the message of the broadcast.
For the rest of this to see if a player has left or not, go to the scratch wiki: https://wiki.scratch.mit.edu/wiki/How_to_Make_a_Multiplayer_Game
Here nearly everything is done the same way. Use the player 1 and 2 checks and the local ones to check if a player has left or not. You could also just do the whole tutorial from there than from here if you want.
Last edited by maximcaux (May 5, 2016 12:48:58)
Hello! Please check out my games, and my second account @GamingUltimate!
when green flag clicked
say [Scratch is awesome!]
- Thinktdm
- Scratcher
79 posts
Cloud Data Help
you have to be a scratcherhow do you do cloud variables? With cloud variables.
Last edited by Thinktdm (May 5, 2016 22:31:15)
SCRATCH TIPS!
Visit https://scratch.mit.edu/studios/30434911/ for a huge library of free custom blocks and neat scripts.
—————————————————————————————————————————————-
when green flag clicked
if <(Old Custom Blocks) = [yes]> then
play sound [Celebration v]
add [custom blocks] to [project v]
else
think [cry] for (90) secs
add [custom blocks] to [project anyway v]
end
- Thinktdm
- Scratcher
79 posts
Cloud Data Help
Well, I already know,but i want to see if there is another way With cloud variables.
SCRATCH TIPS!
Visit https://scratch.mit.edu/studios/30434911/ for a huge library of free custom blocks and neat scripts.
—————————————————————————————————————————————-
when green flag clicked
if <(Old Custom Blocks) = [yes]> then
play sound [Celebration v]
add [custom blocks] to [project v]
else
think [cry] for (90) secs
add [custom blocks] to [project anyway v]
end
- maximcaux
- Scratcher
37 posts
Cloud Data Help
Dont advertise.
And BTW, i know no other way to create multiplayer games than using cloud variables.
And BTW, i know no other way to create multiplayer games than using cloud variables.
Hello! Please check out my games, and my second account @GamingUltimate!
when green flag clicked
say [Scratch is awesome!]
- deck26
- Scratcher
1000+ posts
Cloud Data Help
https://scratch.mit.edu/projects/77775784/ may help - you don't need 7 cloud variables for 2 players but you do have to use cloud variables if by multiplayer you mean people on different computers.
Last edited by deck26 (June 10, 2016 13:41:09)
- GrainedCargo192
- Scratcher
37 posts
Cloud Data Help
KUMQUAT
Fortnite every day!
#StopFortniteHate
Check out my latest project! https://scratch.mit.edu/projects/245172287/
- Bryan007
- Scratcher
100+ posts
Cloud Data Help
Check out @griffpatch .
He makes the best games on multiplayer.
He makes the best games on multiplayer.
quit w
i'll probably only check my scratch account every year or two. if you want to leave me a message, feel free to drop it in my comments, under my profile.
- Thinktdm
- Scratcher
79 posts
Cloud Data Help
I know this thread is 2 months old Check out @griffpatch .
He makes the best games on multiplayer.
SCRATCH TIPS!
Visit https://scratch.mit.edu/studios/30434911/ for a huge library of free custom blocks and neat scripts.
—————————————————————————————————————————————-
when green flag clicked
if <(Old Custom Blocks) = [yes]> then
play sound [Celebration v]
add [custom blocks] to [project v]
else
think [cry] for (90) secs
add [custom blocks] to [project anyway v]
end
- SparkDrawsFurryStuff
- Scratcher
56 posts
Cloud Data Help
yesyou have to be a scratcherhow do you do cloud variables? With cloud variables.
by I am an autistic furry, see my fursona here https://scratch.mit.edu/projects/653935296/
change [fluffiness v] effect by (2x)
- SpinningCube
- Scratcher
100+ posts
Cloud Data Help
griffpatch's youtube channel has a cloud tutorial series
- Discussion Forums
- » Help with Scripts
- » Cloud Data Help