Discuss Scratch

Thinktdm
Scratcher
70 posts

Cloud Data Help

How to I make a Multiplayer game?

———————————————————————————————————-



———————————————————————————————————-





Despacito
wayyyy
Scratcher
100+ posts

Cloud Data Help

With cloud variables.

wuts a signature?

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.
(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!]
rekrab123
Scratcher
15 posts

Cloud Data Help

wayyyy wrote:

With cloud variables.
how do you do cloud variables?
GamingUltimate
Scratcher
8 posts

Cloud Data Help

Look up -_-
Thinktdm
Scratcher
70 posts

Cloud Data Help

rekrab123 wrote:

wayyyy wrote:

With cloud variables.
how do you do cloud variables?
you have to be a scratcher

Last edited by Thinktdm (May 5, 2016 22:31:15)


———————————————————————————————————-



———————————————————————————————————-





Despacito
Thinktdm
Scratcher
70 posts

Cloud Data Help

wayyyy wrote:

With cloud variables.
Well, I already know,but i want to see if there is another way

———————————————————————————————————-



———————————————————————————————————-





Despacito
momo69200
Scratcher
1 post

Cloud Data Help

play to my games svp
maximcaux
Scratcher
37 posts

Cloud Data Help

Dont advertise.

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!]
MellerReal
Scratcher
88 posts

Cloud Data Help

It's not that easy you think it is to create a multiplayer, First you need to get known to cloud vars, Try creating highscore lists, username encrypting etc, Then look at @maximcaux's post, That's the easiest way to create a multiplayer game.

creepershooter
Scratcher
57 posts

Cloud Data Help

momo69200 wrote:

play to my games svp
Don't advertise.

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.

If you ever see an evil kumquat, Always remember that kumquats are fruits and therefore, can't eat your signature

If you want a follower…


And #Bring_It_Back

Thinktdm
Scratcher
70 posts

Cloud Data Help

Bryan007 wrote:

Check out @griffpatch .
He makes the best games on multiplayer.
I know this thread is 2 months old

———————————————————————————————————-



———————————————————————————————————-





Despacito

Powered by DjangoBB

Standard | Mobile