Discuss Scratch

turkey3_test
Scratcher
1000+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

Putting ideas into action—please read the whole thing before thinking it's not a good suggestion

Almost every other topic on this website is “how do I make online games” or a suggestion “online gameplay”. But have you ever thought of how putting that all into blocks could be difficult? Therefore, I propose some very simple blocks on how to make it work. Under “More Blocks” could be online blocks.
search for (2) players and wait //category=custom
What would this do? The script would wait until it find the specified number of players trying to all connect on the same project. When the players are found, the script will continue, here are some more blocks for this:
(player (1 v)) //category=custom
That block would report the name of the player. You can use this block to find out who you are playing with. If no players have been found, it reports blank. The server itself takes the users and assigns each of them a random number, their player #. Each player's username is reported by the block above if their player # is specified in the parameters. Also, if someone has multiple tabs of the same project open, they could play in both tabs as two players.

Okay, you ready for this idea
Using the blocks I showed above, you can figure out which player is you and control a specific sprite from there on. So you can do this:
if <(player (1 v)) = (username)>
set [player v] to (1)
end

when I receive [play v] //this script is in the sprite car A
if <(player) = [1]>
...
end

when I receive [play v] //this script is in the sprite car B
if <(player) = [2]> //each player ends up with his own sprite
...
end
Now for the great idea. If you click the little “i” by a sprite's thumbnail the settings menu appears. There would be an option in the settings menu to “stream sprite values”. Now what does this mean? It means that the x and y position (and direction, size, etc.) of the sprites with this option on are constantly being sent over to the other players so the x, y pos, and direction can be consistent for all players.

So if I change the x position of a sprite with the streaming option selected, the x position would switch for the other players, too. However, it I change the x position of a sprite without the streaming option selected, the x position will only change for me. Because the streaming is optional for sprites, that means players can pull up their own individual menus and selection screens without the other players having to see it.

Clones
Clones inherit the streaming option. If the parent sprite streams data, so will the clones be streaming their own data. Eventually if there are about 100 clones streaming data, on a slow internet connection it could lag, but that is up to the project creator to work around.

More Blocks
(mouse x of [player 1 v]) //category=custom
(mouse y of [player 1 v]) //category=custom

turn [off v] streaming locally //category=custom

More Info on Streaming

scimonster wrote:

Streaming all that data likely will use up lots of bandwidth. I have a few ideas to counter that:
  1. Make sure the user explicitly allows streaming for each project – give them a dialog on projects that stream data, similar to the one for projects that can detect your username. It could say something like: “This project has X sprite(s) that share data between players. Do you want to allow it? If you are on mobile or have poor network speed, we recommend disallowing. The project may not work well without sharing.”
  2. Have a limit on the number of sprites that can stream. Something like 50, counting clones?
  3. Only stream diffs. When you connect, receive all the data. After that, only get/send what changes.
I would like to elaborate on #3. Only when a sprite's value changes will that value be streamed instead of the same value constantly being streamed over and taking up bandwidth.

Last edited by turkey3_test (March 15, 2014 15:08:01)

crazykidz
Scratcher
26 posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

Support, right now I don't even know if there are workarounds. But it's actually not sloppy, it can help especially for the first one. I love it and I want it!
AonymousGuy
Scratcher
1000+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

This would work, although if they make cloud lists, this will be very easy to workaround (except for the fact that cloud lists will most likely be unstable)

Also, just like the “set rotation style” block, I think there should be a block to set whether it can stream.
turkey3_test
Scratcher
1000+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

AonymousGuy wrote:

This would work, although if they make cloud lists, this will be very easy to workaround (except for the fact that cloud lists will most likely be unstable)

Also, just like the “set rotation style” block, I think there should be a block to set whether it can stream.
The rotation style would stream with the option already. Also, cloud lists will take 2 seconds to update probably like variables, and even using cloud lists would be much harder and unstable than the streaming idea, you know?
shredthe3rd
Scratcher
100+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

Blippin' Awezome.
AonymousGuy
Scratcher
1000+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

turkey3_test wrote:

AonymousGuy wrote:

This would work, although if they make cloud lists, this will be very easy to workaround (except for the fact that cloud lists will most likely be unstable)

Also, just like the “set rotation style” block, I think there should be a block to set whether it can stream.
The rotation style would stream with the option already. Also, cloud lists will take 2 seconds to update probably like variables, and even using cloud lists would be much harder and unstable than the streaming idea, you know?
No, I meant that there should be a block that can turn on / off streaming.
mathfreak231
Scratcher
1000+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

Oh yesh, this is one of the more thought-out ideas. Support.
turkey3_test
Scratcher
1000+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

AonymousGuy wrote:

turkey3_test wrote:

AonymousGuy wrote:

This would work, although if they make cloud lists, this will be very easy to workaround (except for the fact that cloud lists will most likely be unstable)

Also, just like the “set rotation style” block, I think there should be a block to set whether it can stream.
The rotation style would stream with the option already. Also, cloud lists will take 2 seconds to update probably like variables, and even using cloud lists would be much harder and unstable than the streaming idea, you know?
No, I meant that there should be a block that can turn on / off streaming.
Support that, too! But by turning off streaming, wouldn't you have to stream that you're turning off streaming?
AonymousGuy
Scratcher
1000+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

turkey3_test wrote:

AonymousGuy wrote:

turkey3_test wrote:

AonymousGuy wrote:

This would work, although if they make cloud lists, this will be very easy to workaround (except for the fact that cloud lists will most likely be unstable)

Also, just like the “set rotation style” block, I think there should be a block to set whether it can stream.
The rotation style would stream with the option already. Also, cloud lists will take 2 seconds to update probably like variables, and even using cloud lists would be much harder and unstable than the streaming idea, you know?
No, I meant that there should be a block that can turn on / off streaming.
Support that, too! But by turning off streaming, wouldn't you have to stream that you're turning off streaming?
Well, I guess. But this would allow you to switch between online / offline mode without extra variables.
scratchisthebest
Scratcher
1000+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

If cloud variables/lists take a number of seconds to stream, what is saying a sprite wouldn't?
Insert argument about how Scratch isn't just for games here. Maybe with a little rewording
wait for (2) users //category=control
(user (2 v) 's name) //category=sensing
a couple more blocks to extend this idea
pretend this down here is a hat block ;)//category=grey
when (2) users on this project //category=events
(user (2 v) 's id) //category=sensing
(user (2 v) 's [mouse x v]) //category=sensing
turkey3_test
Scratcher
1000+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

scratchisthebest wrote:

If cloud variables/lists take a number of seconds to stream, what is saying a sprite wouldn't?
Insert argument about how Scratch isn't just for games here. Maybe with a little rewording
wait for (2) users //category=control
(user (2 v) 's name) //category=sensing
a couple more blocks to extend this idea
pretend this down here is a hat block ;)//category=grey
when (2) users on this project //category=events
(user (2 v) 's id) //category=sensing
(user (2 v) 's [mouse x v]) //category=sensing
Great ideas! I guess the Scratch Team would set up powerful servers so it would only take milliseconds. When you play online games, you are in constant connection with the server, but only when a cloud variable changes does the computer connect to the server, which is why, I think, it takes a couple seconds. Correct me if wrong.
AmayaCreates
Scratcher
100+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

This would take so much effort and time to code. For nowI vote no.
crazykidz
Scratcher
26 posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

AmayaCreates wrote:

This would take so much effort and time to code. For nowI vote no.
Good, that's the point, they have to work hard. It might take long to code, but it is worth it.
ProdigyZeta7
Scratcher
1000+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

Definitely support. Now you need to elaborate on how it will detect all users currently using a project.

Does it exclude anonymous users? What if one user has two tabs open for the same project? How will it tell who gets to be first player, second player, and so on? How reliable will this be for fast-paced games?
turkey3_test
Scratcher
1000+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

AmayaCreates wrote:

This would take so much effort and time to code. For nowI vote no.
When creating an online game, it's not meant to be easy to code with. Personally, I think this would be pretty easy to code with.

ProdigyZeta7 wrote:

Definitely support. Now you need to elaborate on how it will detect all users currently using a project.

Does it exclude anonymous users? What if one user has two tabs open for the same project? How will it tell who gets to be first player, second player, and so on? How reliable will this be for fast-paced games?
1. Non-logged in users will not be able to play unless Scratch decides to start giving them a random username with the username block, because you could not detect which offline user is who. The creator of the project could program the online capabilities to be disabled if the user is offline.

2. If the user has open multiple tabs, I'm not quite sure. Maybe your player # can be not only linked to your username but IP address, too, so you cannot play as two players from the same IP.

3. The server itself will tell who is which player. It'll take each user and give them each a number randomly.

4. For fast-paced games, it depends on how much data needs to be streamed. With my internet I can download files online at about 3 megabytes per seconds, so unless the project needs to stream over about 2 megabytes of data per second, speed should be fine. Sending over x, y positions, costume #s, direction, etc. should not exceed a small number of bytes. If about 100 sprites were streaming, your computer would probably be reading 1mb of data every second (remember each frame). As for sending out data, when you change the value of a streaming sprite, your computer streams out the data which the server will change and send back to each computers.

Last edited by turkey3_test (Dec. 24, 2013 14:54:06)

Photoguy77
Scratcher
100+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

I support!!!
MCAnimator3D
Scratcher
500+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

This is what @relrel's multiplayer system does. I used this in my "Parkour" multiplayer game

Last edited by MCAnimator3D (Dec. 24, 2013 15:06:07)

scimonster
Scratcher
1000+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

This happens to be a pretty well-thought-out idea, i like it! And it doesn't have to be only for games, you could also do realtime art, or watch animations together….

turkey3_test wrote:

AonymousGuy wrote:

No, I meant that there should be a block that can turn on / off streaming.
Support that, too! But by turning off streaming, wouldn't you have to stream that you're turning off streaming?
No, you wouldn't. It would unstream locally.

EDIT: Streaming all that data likely will use up lots of bandwidth. I have a few ideas to counter that:
  1. Make sure the user explicitly allows streaming for each project – give them a dialog on projects that stream data, similar to the one for projects that can detect your username. It could say something like: “This project has X sprite(s) that share data between players. Do you want to allow it? If you are on mobile or have poor network speed, we recommend disallowing. The project may not work well without sharing.”
  2. Have a limit on the number of sprites that can stream. Something like 50, counting clones?
  3. Only stream diffs. When you connect, receive all the data. After that, only get/send what changes.

Last edited by scimonster (Dec. 24, 2013 15:27:30)

Chainmanner
Scratcher
100+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

No support. I'm pretty sure it can be done with current standards.
turkey3_test
Scratcher
1000+ posts

Scratch 3.0— Online games— But Wait— I Have a Way it Can Be Done

scimonster wrote:

This happens to be a pretty well-thought-out idea, i like it! And it doesn't have to be only for games, you could also do realtime art, or watch animations together….
Thanks! The real-time art gave me an idea:
turn pen streaming [on v] //category=pen

Powered by DjangoBB