Discuss Scratch

hmdmner
Scratcher
23 posts

Cloud multiplayer games

I was making a multiplayer game but it didn't work.
hedgehog_blue
Scratcher
1000+ posts

Cloud multiplayer games

Yes, it's hard. The main difficulty is getting data connection timed and keeping players timed up so that they don't use the variable(s) at the same time. Each player will have to not get in the way of live data transfer while joining, so they will have to have a join variable to get put into the cycle. If other players are trying at the same time, a player will have to continue trying until competition stops or they get accepted by other players. The joining player needs to keep checking if any players are currently in the cycle, and because those players will not be there to say they have left, they clearly cannot remove themselves. And so, when removing players, each player must stay active by changing a number (supposingly small, because of length restrictions - we'll get into that later) each time they get cycled to. Other players, after time of no activity from a player, will send their data in and remove the other player. The cycle continues, and each player will save the data sent in locally to be rendered or used/altered. In terms of response having to come from other players, it is tough to determine who gets the right-of-way in creating a reaction to in-game actions. The cycle may take a while for the transfer of data, especially if players are leaving or joining, so it will be hard to have proper reaction when a player does anything to another player. This is up to you to do as best as possible, maybe by taking the probability of each action taking place to determine which is stronger. It needs to send a small amount of data each turn, and cycle slow enough so that data does not get changed again before a player realizes that it has been changed and updates it to the current conditions. It needs to send a small amount of data, because of the cloud variable length limit of 128 characters in a variable at a time. This can be done best by sending multiple chunks of data separately or encrypting data as much as possible, but these are slow. The best way to eliminate data use is to simply have as little of it needed to be shared as possible. This is only the basics, so to get started, you will need to have a good understanding of coordination of multiple players via a variable. Currently resources like the scratch wiki either only give extremely basic ways to do things, or are not updated to the current cloud variable conditions. I hope you can still use some of this information to work out a way to do this, but again, this is only the basics.

edited to bold the sentence about 128 characters so that others don't think that I forgot about that - multiplayer is still very possible despite the data length limit.

Last edited by hedgehog_blue (March 7, 2018 01:06:31)















hmdmner
Scratcher
23 posts

Cloud multiplayer games

I think I may have found something in the code.
deck26
Scratcher
1000+ posts

Cloud multiplayer games

I think it's easiest to stick to one player per cloud variable. If a cloud variable is changing that player slot is in use. No conflict with players trying to update at the same time. Restricts you to 10 players but saves a ton of work and shortened cloud vars mean combining players is of limited use anyway.
hmdmner
Scratcher
23 posts

Cloud multiplayer games

If you wanted to see it go to Draw multiplayer (https://scratch.mit.edu/projects/208148600/#player), In it there are three cloud variables for each sprite: (although “cloud” is the cloud symbol)
(cloudx)
(cloudy)
(cloud this sprite state)
deck26
Scratcher
1000+ posts

Cloud multiplayer games

hmdmner wrote:

If you wanted to see it go to Draw multiplayer (https://scratch.mit.edu/projects/208148600/#player), In it there are three cloud variables for each sprite: (although “cloud” is the cloud symbol)
(cloudx)
(cloudy)
(cloud this sprite state)
One cloud variable per player is enough though - see https://scratch.mit.edu/projects/77775784/

Last edited by deck26 (March 7, 2018 16:11:37)

Powered by DjangoBB

Standard | Mobile