Hi,
I want to make a simple multiplayer cardgame. The twist is, I want the table to be shown on a desktop, while each player has his own cards shown on a smartphone. That means I need a way to:
-Have a smartphone version, wich will only show the cards one player has, allow the player to deal the cards that can be dealt and get new cards.
-Have a desktop version, wich will know wich player is active, wich cards each player has, wich cards can be dealt, show the gameboard, get cards as the players deal them.
How would I make something like that?
That’s a good question. I haven’t made anything like that.
What I would do is have both the clients (smartphone) and server (table) all the same scene and same program. I would share all network data so everybody has access to everything. (A turn based card game won’t have much network traffic so it’s probably OK to be inefficient lazy)
Then since everybody has access to everything what I would do is
-For the server display a GUI of the table (and hide the client GUI)
-For the clients display a GUI of their hand (and hide the server GUI)
I think this is the easiest way to do things. However, if you are concerned about network bandwidth efficiency, or cheating, or minimizing the build file size for client (smartphones) then you could do things differently, but it would be much more complicated.
So it sounds like you want to build a virtual poker game where everyone is physically there, protecting their hand by viewing it on their smartphone, but watching the table action on the “desktop” version. Sounds pretty interesting.
I’d probably do all the network communication using Messages. I’d have a server that runs a NetworkServerSimple that the desktop and phones all connect to. The server sends the phone clients their own cards via Messages, but not necessarily other players’ cards. The desktop version tells the server it is a desktop when it connects, which then causes the server to send all card info to the desktop client.
When using NetworkServerSimple and Messages your network communication is independent of the scene you’re running. So your server can run a server scene, desktop can run a desktop scene, and phone can run a phone client scene without issue. You could also consider having the desktop and server be a single entity, so the server displays the desktop and the phones connect to this server/desktop instance.
The only example I’ve ever found using NetworkServerSimple is the old chat server example project. But when I was learning to use it I found it helpful enough.