Microsoft MakeCode

New Extension: Real Multiplayer (with blocks)

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.

image

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

image

The following block, tells the extension who are each player and how they will be moved
image

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"

image

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

image

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

3 Likes

Hi,
I had trouble with regular jacdac extension and during research I saw this extension. Great work. I’m working on 2P snake game and I migrated code to use your extension:


It reduced code a lot and it’s easily to understand but it doesn’t work. One screen is active and other one is frozen. I’m not sure what’s problem. Do you have time to check it? Thanks.
P.S. I don’t have classical player sprites. Because of snake’s nature it is list of sprites. During movement i remove last sprite and add new one at the beginning, based on direction, which is defined by button inputs. When snake eats food, last sprite isn’t removed. Food is generated randomly. Without move player1 player2 vx100 vy 100 I got error so I added dummy command. Same behavior is when I add 2 dummy sprites which serves as player sprites.

Hi @bosnivan thanks for testing it.

Seems that your game is too advanced for my experimental extension.

I’ve seen your code and it will help me to improve the extension. Note that the current extension is very basic and has been donde based on a typical projectile shooting game, so i must adapt it to more kind of game situations like yours

I’ll post changes when i had a new version ready…

@EnteroPositivo, when you post your updated version of Real MultiPlayer with blocks could you please post a Github link if you have it in that repository as a MakeCode extension? I know you have it installed on your game and that works for me with GHI BrainPad and Meowbit. I would like to use your extension now with the Robotbit extension and when I do that in Arcade and add Robotbit into your game the compiler sees a conflict. Often when this happens I can go the other way and install the new extension (yours) into a program with Robotbit already installed and the Arcade compiler will then accept that program as no errors. Thanks

Thanks for the checking. Don’t feel rushed because of me. Just reply when you make changes. :slight_smile: