Microsoft MakeCode

Multiplayer with hardware and blocks?

Hi All.

I have made some games using the multiplayer blocks avaliable ( move player 2 with buttons, change player 2 score , … ) , also i’ve tested other ones made buy users

When i upload those games to two consoles joined with jacdac, those games made with blocks don’t work in hardware they are only playable within the simulator

I thought that making a multiplayer game with blocks will act as multiplayer games once detected a jacdac connection but seems that this doesn’t work like i expected.

- Am i right or i am missing somehting ???

Then i’ve fount the forum thread

were there is a real multiplayer game that i can play in my consoles connected via jacdac, but that game is made using JavaScript instead of using blocks, so users learning makecode arcade with blocks can not make their own multiplayer games.

There is an existing jacdac-game extension but there isn’t information about how to use it neither how to use ControllerServices class. An extract of a portion of code from that class is:

...    
private askJoin(device: JDDevice): boolean {
            game.eventContext(); // initialize the game
            control.pushEventContext();
            game.showDialog("Arcade Detected", "Join?", "A = OK, B = CANCEL");
            let answer: boolean = null;
            controller.A.onEvent(ControllerButtonEvent.Pressed, () => answer = true);
            controller.B.onEvent(ControllerButtonEvent.Pressed, () => answer = false);
            pauseUntil(() =>
                // user answered
                answer !== null
                // server got joined
                || this.hasPlayers()
                // other driver dissapeared
                || !jacdac.devices().find(d => d.device_address == device.device_address)
            );
            // wait until we have an answer or the service
            control.popEventContext();

            // cache user answer
            if (answer !== null)
                this.promptedServers.push(device.udidl);

            // check that we haven't been join by then
            return !!answer
                && !this.hasPlayers()
                && !!jacdac.devices().find(d => d.device_address == device.device_address);
        }
...

so i see that there is code made for this purpose

Is this class which make possible to have a real hardware multiplayer game done using blocks without doing any more, or anybody has any sample on how to use jacdac-game extension or this class ?

Perhaps was a big post, so i only want to know.

Can anybody make a multiplayer game to play with real consoles (syncthing sprites, …) using blocks ( not JavaScript) ?

( If not, then i will make an extension to do it )

Nope, we do not have blocks yet for hardware multiplayer. The only sample we really have for jacdac right now is the game you linked. There is some more info about jacdac and some helpful debugging tools here: https://jacdac.org/

Thank you @richard

It’s almost done. I’ve made an extension to allow Real Multiplayer based on your JavaScript code

You can create a multiplayer game to play both on simulator and also download to consoles, it syncs any kind of srpites and shares images between consoles.

At the moment here is a screenshot, i must make some improvement and refactoring and i’ll make a post showing how to use the extensión :wink:

Excellent! Do you have a github repo for this extension?

Yes i have it, give me one or 2 days more to make a stable versión and i will post all details

1 Like

@EnteroPositivo you can usually detect whether or not you are in simulator by checking the available RAM so that the user doesn’t need to remember to flip that switch.

I think internally we use control.ramSize() > 1024 * 200 to check if we are in the sim

Alternatively control.deviceDalVersion should return string sim. It will be linux on RPi and sem version otherwise.

Some sort of feature detection might be eventually needed though…

The switch is needed for this cases:

1- When you want to test your custom wait screen in the sim

2- When you need to play the game in the sim

Anyway you have give me a good idea, to use your check sim formula and when in console “wait allways for connection” no matther the possition of that switch

So that switch will only works in sim mode

1 Like