Game for two using Remoting

derez

Expert
Licensed User
Longtime User
Using Agraham's new Remoting library, I wrote a simple game as an example of how this library can be used for two players games.

I tried to keep it as simple as possible. Here is a description of the code:

The game is called "X Mix Drix" (at least where I live) and you must know it.
There is only one application, each player selects his number, but no. 1 must press first since he is the server.
The game status is kept in the game() array and the program updates it in both players application using setdata and getdata .
The program connection is for running on the same computer as I believe it still needs a lot of development as a baseline for more advanced games. To convert it for LAN or WAN - look at Agraham's examples.

I'll be happy to see an addition to the library, for connection status report, instead of errors...in the program I keep a flag to hold the status.

I wish for and expect comments and corrections, to help me and others advance with this library.

Thanks again,Agraham :)

Edit: updated to version 2, enabling selection of local host or LAN, eliminating cheating and ending game when there is no winner. New game is launched by pressing again on player1 and player2 respectively.

Edit: upgraded to ver 3 , using remoting 1.1 lib. The code is commented for clarity.

3_2 use one dimension array, 3_3 - two-dimension.
 

Attachments

  • Xmix3_2.sbp
    6.9 KB · Views: 370
  • Xmix3_3.sbp
    7.2 KB · Views: 364
Last edited:

derez

Expert
Licensed User
Longtime User
I have updated the file in the first post to ver 2.1
The flag showing the connection status is now included in the game array, as no 10.
With this there is a way to better control the connection and refrain from error messages.
 

derez

Expert
Licensed User
Longtime User
Version 3.1 re-arranged and tested between two computers on LAN and between desktop and device (WM5) through activesync connection (also LAN, see network library help on how to find the host name).

From here to a Chess game is "just" to:
1. increase the board to 8x8 and the array accordingly
2. Tools images
3. MMI to select the tools, place them and move them.
4. define moving rules - what is allowed and what isn't
5. Define game result criteria
6...

So it is still a lot of work :( , but only on the game itself, the management of connection stays as is :)

Edit: checked between two devices using Wi-Fi. I added display of the IP after server starts, to help the client find its server.
 
Last edited:

derez

Expert
Licensed User
Longtime User
Version 3_3 is using two-dimesional array instead of one dimension, to make the adaptation to square board games easier.
The 0 cells in both dimensions can be used for flags.
 
Top