iCloud Multiplayer! Guess The Number Game

4

SP4CEBAR 2025-10-07 14:40 (Edited)

We Have Online Multiplayer!


        Open In Editor (single player)


How Is This Even Possible!?

An NX program can save and load data to a file named "Disk.nx". On IOS, your NX programs, including your Disk.nx, are stored on iCloud, but other platforms could do this as well. iCloud allows collaborating on a file online with others, so I shared Disk.nx files with all of you (see section Servers). When using a shared Disk.nx instead of your current Disk.nx, your program can "talk" to others that use the same disk.

This program is made to play a simple game as turn-based online multiplayer. I expect the program to be easily modify-able for other turn-based online games.


Gameplay

note: Choosing a player count of 1 allows playing single player so you can try it out below.


How To Set Up Multiplayer


Other Important Topics


Game


Technical details below


SP4CEBAR 2025-10-08 15:41 (Edited)

Technical details


Multiplayer Example Code

Turn based

You may treat this code as an example of a turn-based multiplayer game, you could for example modify it into a card game.

Reveal

If you are more adventurous, you could mess with the code to make different multiplayer rules: game where each player can prepare their moves all at once before the result of them is revealed, like rock paper scissors.

All at once

You could even try to let each connected program modify their file (channel) continuously to sync the states of more action-packed games.


Improvement Ideas

  1. Clients get the same ID if they join at the same time and become indistinguishable
    • have each client save a timer variable, to file 4 + TIMER MOD 12
      • this allows a two clients that joined near each other to be identified
      • there is still a 1 in 12 chance that both clients still wrote to the same file, in which case one of them may not be able to see the other's message.
      • I think the timer is counted since the app opened, PC clients that run an NX programs on boot may have the same timer value when they join

SP4CEBAR          a sneaky markdown trick

Update 1: essential fixes

I tested it on Linux by running two NX instances and it actually works!


SP4CEBAR 2025-10-08 19:47 (Edited)

Update 2: reliability and clarity


jpospTynker 2025-10-09 00:02

this is SICK! it’s crazy multiplayer works in LOWRES NX now


SP4CEBAR 2025-10-09 11:51

I'm glad you like it!


SP4CEBAR 2025-10-09 13:49 (Edited)

Update 3: party player


SP4CEBAR 2025-10-09 14:37 (Edited)

I shared a Disk with all of you!

Now you can play multiplayer on IOS! See program desciption above for more details.

Please let me know if you managed to open and modify the Disk, with an NX program on platforms other than IOS. I also just updated the description to provide more instructions and details.


SP4CEBAR 2025-10-09 16:24 (Edited)

Update 4: single player


jpospTynker 2025-10-09 21:42

this is awesome, definitely doing something with this! imagine 12-player Co-op with fellow NXers!


SP4CEBAR 2025-10-10 13:06 (Edited)

I love the enthausiasm! I updated the instructions to make it clear for most platforms how to play.

All we need now is to arrange a time when anyone that wants to play will be online to play!
...as well as a joining order (with around 30 seconds between each joining player)


SP4CEBAR 2025-10-10 13:22 (Edited)

Also, if anyone wants to modify this turn-based online multiplayer example into a more complex game such as a card game, feel free to do so:


SP4CEBAR 2025-10-10 18:45 (Edited)

Update 5


SP4CEBAR 2025-10-11 06:35

Update 6


SP4CEBAR 2025-10-11 08:51

Here's an invitation to play multiplayer: Do You Want To Play The First Online Multiplayer Game?


Software Center 2025-10-11 14:38

Ummm I’m kinda confused could you simplify it. Btw I’m on iOS


SP4CEBAR 2025-10-11 20:00 (Edited)

Thanks for the feedback!
TL;DR An NX program can save data to a file named "Disk.nx". On IOS, your NX programs, including your Disk.nx, are stored on iCloud. iCloud allows collaborating on a file online with others, so I shared a Disk.nx with all of you (two actually, see section "Servers" above). When using this shared Disk.nx instead of your current Disk.nx, your program can "talk" to others that use the same disk. This program is made to play a simple game as turn-based online multiplayer. I expect the program to be easily modify-able for other turn-based online games.


jpospTynker 2025-10-11 20:20

woah now i wanna make a 4 player platformer


jpospTynker 2025-10-11 20:21

imagine r/place or something with this


SP4CEBAR 2025-10-12 06:16 (Edited)

Good luck, feel free to use code from here such as the connection phase. You can test multiplayer by opening an NX program twice on PC to launch two instances, you won't need any cloud for this. The possibilities are endless,


SP4CEBAR 2025-10-12 14:46 (Edited)

Update 7

code comparison

before

Even though it's short, it is hard to read what it does

MULTIPLAYER_TURNS:
  IF TARGET_CLIENT_COUNT > 1 THEN GOSUB RIVAL_TURN
  IF CLIENT_ID = TURN_ID OR TURN_ID = -1 THEN GOSUB YOUR_TURN
RETURN

after

This is much more straightforward

MULTIPLAYER_TURN:
  IS_YOUR_TURN= TURN_ID = CLIENT_ID
  IF IS_YOUR_TURN THEN
    GOSUB YOUR_TURN
  ELSE 
    GOSUB RIVAL_TURN
  END IF
RETURN

We also don't need the IS_YOUR_TURN variable anymore


jpospTynker 2025-10-12 15:07

i will try to make a platformer from this, with the acceleration the only thing online and the positions being stored in the game itself, but i still feel it will be nonstop conflict issues i have to fix :/


SP4CEBAR 2025-10-12 18:30

Good luck, have fun!


cmos 2025-10-14 02:30

too bad i don't have icloud D; (or anything apple for that matter)
i might try to get a google drive disk.nx up,
but no promises!


SP4CEBAR 2025-10-14 11:19 (Edited)

Good luck! note that the "Disk.nx" file has a capital "D", otherwise NX may not be able to find it.

You could also create a new apple account here, it does not require any apple device, but will give you 1GB instead of 5GB of iCloud drive. It also won't give you an "@icloud.com" email account


Log in to reply.