Ok, so I am definitely on board with games for Zune and hoping this thing really takes off.
The killer feature will definitely be multiplayer here. I really want to develop some multiplayer apps to carry the Social to an all new level.
The only thing is, all of the current multiplayer code is for Windows and Xbox. Does anyone have any pointers as to where I could start to see how multiplayer works on the Zunes?
Working sample code would be awesome if there is any out there.
There really isn't. I only found one page of stuff on the Zune in the MSDN docs that come with the new version. All of the multiplayer docs are currently for Xbox and PC, which include stuff that the Zune doesn't have, I am pretty sure.
I've started writing a small multiplayer game and I've managed to get 2 Zunes connecting through XNA. Actually it's quite easy using the XNA, I used System Link as the type of connection.
It's quite unreliable at this point (e.g. it crashes many times when trying to join, in some cases I have to restart the game on both zunes to make it work). I don't know if that's because I'm doing something wrong or if there are some issues in the CTP.
This is my first attempt to write any networking code using XNA so please take it with a grain of salt. My code is quite unreliable at this point (e.g. connect than disconnect than try to connect again throws exception - the only solution I found so far is to restart both zunes). But, if the stars are properly aligned, it will get the 2 zunes connected. If they don't connect, restart both zunes and try again.
I don't have any code to send any data between the 2 zunes.
Instructions:
- Deploy the code on both zunes (you need to make the Zune active in the Device center).
- Launch the application on both zune
- 1st zune (host): Press Up on DPad so that it hosts the game. The background will turn blue and the Zune will start hosting a game
- 2nd zune (client): Press Down on DPad so that it tries to join an existing game. The background will turn red and the Zune will stat looking for a game. If it finds one, it will try to connect to the first one it finds.
If everything worked fine, the 1st zune should say "Player joined".
Awesome. I've been using this as my base code for multiplay; Man, this stuff is confusing! From my understanding, there is no way for the server to simply say
player2.get(xPosition);
//based on xPosition, modify game's screen
drawScreen(this, player2)
Man, that would be nice... Someone prove me wrong!
Awesome, that would great. A friend of mine made a sweet game that I was planning on adding network support and porting the Zune. It'd be a huge help to have some real code to go off of. Microsoft's documentation really sucks.
Here is a working example that is pretty simple but does the job. Just launch the app, and if you are lucky enough to have more than one Zune to play with, launch it on the other one a few seconds later, and they will automatically connect.
Pressing the D-Pad will send a string with the Gamertag of the user that clicked the pad, and the direction they clicked. Just a simple illustration; you would want to do it a bit differently in a game.
The code is based primarily off of Adrian Vinca's example posted above, the tank example on the XNA site, some coffee and some of my gray matter.
Please feel free to look through this code, adapt it to your needs, use it in your games etc. Also, if someone finds mistakes or better ways of doing things, please let me know!
Here is a working example that is pretty simple but does the job. Just launch the app, and if you are lucky enough to have more than one Zune to play with, launch it on the other one a few seconds later, and they will automatically connect.
Pressing the D-Pad will send a string with the Gamertag of the user that clicked the pad, and the direction they clicked. Just a simple illustration; you would want to do it a bit differently in a game.
The code is based primarily off of Adrian Vinca's example posted above, the tank example on the XNA site, some coffee and some of my gray matter.
Please feel free to look through this code, adapt it to your needs, use it in your games etc. Also, if someone finds mistakes or better ways of doing things, please let me know!