Thanks to the code developed by @richard i’ve made an extension to allow make multiplayer games using blocks that runs in the simulator and downloading to consoles connected via jacdac.
I have tried to make the programming as inontrusive as possible for the user.
Game Explained
Designing a wait screen
There is a wait for connection screen when both consoles are switched on that you can customize as usual.
Game start
Switching OFF this block, you can program and test the game in simulator mode as allways.
When the connection is detected between both consoles, the following block is executed . This is the start point where game real starts so you can program here what you want like typical “on start” block but on multiplayer mode
The following block, tells the extension who are each player and how they will be moved
Syncthing images between consoles
You need to specify all the images that will be synced between the consoles once game has started.
Usually are the moving images like “enemy”, “food” and “projectiles” that are created and destroyed.
Master loop
Is the master loop that controls the game story, in this case it creates random enemies.
The extension will sync automatically the sprites with their images
Note: The images aren’t sent via jacdac, only their UIDS calculated with the prevo¡ious block "shared images"
Buttons and projectiles
The buttons of both players must be controlled within the same function
But i have created the block “is player 1” to detect if the button is pressed by player 1 or player 2.
Note: This also works in simulation mode
There is another helper block that can be used to tell the game who owns each projectile
Scores
Control each scores as allways, you can check who has shooted a projectile
Tested with OK:D51 pro
Here is the game tested with two consoles OK:D51 pro
The extension
You can use the extension by entering the folloing URL
https://github.com/distintiva/pxt-real-multiplayer
NOTE
The extension is very recent, i must improve and try to solve some connection bugs and stability.
Also add more common games characteristics