Discuss Scratch

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
wayyyy
Scratcher
500+ posts

Cloud Data Help

With cloud variables.

Delete your Scratch Account

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
79 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)


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

wayyyy wrote:

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

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
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
59 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.

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

Bryan007 wrote:

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

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

Thinktdm wrote:

rekrab123 wrote:

wayyyy wrote:

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

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
AntonL1kesPotato
Scratcher
1000+ posts

Cloud Data Help

SparkDrawsFurryStuff wrote:

Thinktdm wrote:

rekrab123 wrote:

wayyyy wrote:

With cloud variables.
how do you do cloud variables?
you have to be a scratcher
yes
Please don't necropost.










Making games on Scratch and learning other engines/frameworks. Also likes to make music using trackers.
































































You are using extensions, aren't you?

Powered by DjangoBB