Discuss Scratch

Burgame-Productions
Scratcher
59 posts

Making A Multiplayer Racing Game

I am back, and on my project, Scratch Cat Racing, I am working on an update that will be adding Online Play, I have seen projects that have this option, but I am looking for tips on how to do that. Help is very much needed.
define☁highscore=100
codeman1044
Scratcher
1000+ posts

Making A Multiplayer Racing Game

You should use 4 variables at minimum: player1x, player1y, player2x, and player2y. These will be updated when you use the arrow keys instead of the x/y position of the sprites. Since the variables are cloud variables, this will update live.
Burgame-Productions
Scratcher
59 posts

Making A Multiplayer Racing Game

Okay, thanks for the tips, it sorta looks like this? I know the variable would really be a cloud variable

foreverifkey wpressed?thenchnageyby4set player1's positiontoyposition

Last edited by Burgame-Productions (May 8, 2019 13:04:55)

imfh
Scratcher
1000+ posts

Making A Multiplayer Racing Game

Burgame-Productions wrote:

Okay, thanks for the tips, it sorta looks like this?

foreverifkey wpressed?thenchnageyby4set player1's positiontoyposition
You could do something like that, but it might disconnect from the cloud server. The forever loop runs 30 times a second. Setting a cloud variable that fast sometimes causes the server to disconnect to prevent it from being overloaded. It's possible you won't have that problem, but you might want to try something like this instead:

foreverset☁ Player1Xtoxpositionset☁ Player1Ytoypositionwait0.1secs Delay to slow it down a bit In the player spriteforeverglide0.1secstox:Player2Xy:Player2Y Glide smoothly rather than jump every 0.1 secs In the other player sprite

The glide block will make the other player move smoothly even if the game lags. You will also need some if blocks so it knows whether the player is player 1, 2, or not playing.
Burgame-Productions
Scratcher
59 posts

Making A Multiplayer Racing Game

imfh wrote:

Burgame-Productions wrote:

Okay, thanks for the tips, it sorta looks like this?

foreverifkey wpressed?thenchnageyby4set player1's positiontoyposition
You could do something like that, but it might disconnect from the cloud server. The forever loop runs 30 times a second. Setting a cloud variable that fast sometimes causes the server to disconnect to prevent it from being overloaded. It's possible you won't have that problem, but you might want to try something like this instead:

foreverset☁ Player1Xtoxpositionset☁ Player1Ytoypositionwait0.1secs Delay to slow it down a bit In the player spriteforeverglide0.1secstox:Player2Xy:Player2Y Glide smoothly rather than jump every 0.1 secs In the other player sprite

The glide block will make the other player move smoothly even if the game lags. You will also need some if blocks so it knows whether the player is player 1, 2, or not playing.

Okay, I didn't think about that,
thanks for the extra information!
Mr_Custom
Scratcher
100+ posts

Making A Multiplayer Racing Game

This tutorial might be helpful for your player kicking and joining: https://scratch.mit.edu/projects/297268676/
raptor_rexer2341
Scratcher
2 posts

Making A Multiplayer Racing Game

taco
Wainggan
Scratcher
500+ posts

Making A Multiplayer Racing Game

raptor_rexer2341 wrote:

taco
No necroposting
bgscratchgamesmaker
Scratcher
1 post

Making A Multiplayer Racing Game

I had same one I just want a multiplayer I used cloud variables too but it did not work I used my brother's computer too see that but It did not work is there's a solution?

Powered by DjangoBB