In my current attempt I’d like to have each player see different items. Think of a simple poker style game where each connected player sees their own hand and no one elses.
I’ve dug around and I really can’t find a way to say “current controller”. From what I’ve gathered all of the code is global and shared across all players. So right now I have an object assigned to each player as they are connected:
psudo code:
on connect: player -> { cards: [], controller: getControllerBasedOnIndex(player.index) }
The above psudo code simply creates an array of players, each with some meta-data around their assigned controller. The controller is figured out controller.player1 etc based on the player.index but there’s no way I can figure out which player index (or controller) the current player is!
I can see the current implementation of multiplayer says that “all players control a sprite at the same time” which works well for “everyone sees the same screen” but there doesn’t seem to be a way to say “you are player 2, show only player 2 items”.
Ideally when I click the different player icons in the simulator, the screen will change to that players view. But without the ability to say “the current player is X” it’s impossible to do any specific logic based on who you are.
Separate screens for each player in a multiplayer setup is something up for consideration in future versions of MakeCode Arcade. It is not available in its current version.
Thank you. I’ll keep an eye on it.
I have dreams of having two devices with their own views, but I can see how this would become troublesome if you need to support two views on a single screen.
Given the nature of two screens already when you share links and two physical devices for the hardware option. I would think a simple “who’s active” type of step would be a reasonable first step.
The hardware solution may be the easier of the two to accomplish, although I don’t recall where we are regarding the interconnect messaging software.[1] Separate “screens” via network multiplayer is a much taller order, but the MakeCode team loves working on challenging problems. It’s on the back burner, but the pot is always simmering. Stay tuned.
[1] MakeCode Arcade has supported Jacdac in a variety of incarnations, but I haven’t seen anything new on that front in a while.
Jacdac is exactly where I’m looking now and it may actually fit the bill (if I can figure it out).
Seems the jacdac project mostly focuses on attaching external devices, not so much two meowbit style controllers directly.
However I did find this github issue: https://github.com/microsoft/jacdac/issues/1308 that appears to attempt to do what I’m thinking. Any maybe this worked as a pure jacdac connection before the multiplayer addition? Right now jacdac doesn’t seem to have an easy way to directly connect two meowbit controllers directly at least out of the box…
It’s ancient, so don’t expect any of the code to work, but it might serve as inspiration. Fundamentally, Jacdac hasn’t changed since then, but I know the APIs have changed.
Thanks a ton. I wandered through that link and some of the discussion in there. I decided that the jacdac was a little too complicated for me and just ordered up the mewbit wireless sd card.
This is outside the original topic of “Current Controller”, I’ve decided to build two games:
One that has multiplayer but sharing the same screen (side scroll beat-em-up) - This will be web based and use the new multiplayer blocks (which are awesome btw)
One that simply transmits some game state information but run independently on two different meowbits using the sd card … so “multiplayer” but not using the multiplayer blocks