Programming4us
         
 
 
Windows Phone

Developing for Windows Phone and Xbox Live : Multiplayer Games (part 1) - Getting Ready for Networking Development

7/18/2011 5:42:27 PM
Multiplayer games enable the game player to enjoy the cooperation or competition from other players. Before computer networks were popular, this was normally done by enabling multiple players to play on a single television screen. Games can enable both players to be displayed on the screen at the same time and place or can offer multiple points of view by splitting the screen into multiple areas called split screen.

Many gamers today enjoy the availability of high speed Internet access. Personal computers and gaming consoles can connect over the Internet to enable multiple players to be connected together while playing their games.

XNA Game Studio 4.0 provides the capability to create, find, and connect to network sessions between Windows PCs using Games for Windows LIVE and Xbox 360s using Xbox LIVE. The networking APIs that you will use are part of the Microsoft.Xna.Framework.Net assembly and use the namespace of the same name. If your Windows or Xbox 360 project does not currently reference the Microsoft.Xna.Framework.Net assembly, then add the reference now. You need the reference of the samples for the remainder of this article. You can also add the using statement for the Microsoft.Xna.Framework.Net namespace to your Game class. Add the following line of code to your C# file that contains your Game class:

using Microsoft.Xna.Framework.Net;

Getting Ready for Networking Development

Building a multiplayer networked game requires that you have more than one machine that is running your game. One common development scenario is to build your game to run on both Xbox 360 and Windows. Because XNA Game Studio supports building your project for both of these platforms, you can create your game, deploy the game to your Xbox, and run the Windows version at the same time.

Running an XNA game that uses networking during development has some requirements for the gamer profile that is playing the game. On Xbox 360, the gamer profile must have an XNA Creators Club membership. Because the same membership is required to do XNA development on Xbox 360, you should already have that requirement out of the way. The other requirement on Xbox 360 is an Xbox LIVE Gold membership to connect a Player or Ranked session over the Internet. Only a Silver membership is required if you use SystemLink, which enables multiple machines to connect over a local area network—that is what you normally do when developing your game.

On Windows, only a local Games for Windows LIVE is required for building a game using SystemLink. If you use a profile that has a Silver or Gold account, you also need an XNA Creators Club membership. Because you will develop over SystemLink, you should not need a second XNA Creators Club membership. Use a local account or you will get an exception.

To use the networking APIs in XNA, initialize GamerServices.

Add the following code to your Game class constructor:

graphics = new GraphicsDeviceManager(this);
graphics.PreferredBackBufferWidth = 1280;
graphics.PreferredBackBufferHeight = 720;
Content.RootDirectory = "Content";
// Initialize GamerServices
Components.Add(new GamerServicesComponent(this));

If you run the game on Windows, the game runs Game for Windows LIVE (see Figure 1).

Figure 1. Game starting Games for Windows LIVE

Press the Home key to bring up the guide in Game for Windows LIVE (see Figure 2).

Figure 2. Games for Windows LIVE guide

If you already have a profile signed, sign the profile out so that your screen looks like Figure 2.

Now, create a local profile. To do this, select Create New Profile located in the middle button area of the guide.

Note

You can use the keyboard, mouse, and Xbox 360 controller to interact with the Game for Windows LIVE guide. In this article, the samples assume you are using a wired Xbox 360 controller plugged into your PC.


After you click the Create New Profile button, scroll down to Create a Local Profile link and click the link (see Figure 3).

Figure 3. Creating a local profile in Games for Windows LIVE

Complete the process to create the new local profile. You can select to have that profile auto login when you start, which saves you time while you are develop the game and saves you the step of having to sign in the local profile every time you start the game.

Other -----------------
- User Interface : Using the ApplicationBar Control
- User Interface : Creating an Animated Splash Screen
- Windows Phone 7 Game Development : The World of 3D Graphics - Vertex and Index Buffers
- Windows Phone 7 Game Development : The World of 3D Graphics - Hidden Surface Culling
- Windows Phone 7 Game Development : The World of 3D Graphics - The Depth Buffer
- Windows Phone 7 Game Development : The World of 3D Graphics - Rendering 3D Objects
- Windows Phone 7 Game Development : The World of 3D Graphics - Perspective Projection
- Developing for Windows Phone and Xbox Live : Let the 3D Rendering Start
- Developing for Windows Phone and Xbox Live : Reach and HiDef Graphics Profiles
- Developing for Windows Phone and Xbox Live : Graphics Pipeline
- Developing for Windows Phone and Xbox Live : Graphics Pipeline
- Programming Windows Phone 7 : Elements and Properties - More on Images
- Programming Windows Phone 7 : TextBlock Properties and Inlines
- Programming Windows Phone 7 : The Phone’s Photo Library
- Programming Windows Phone 7 : Capturing from the Camera
- Windows Phone 7 : Loading Local Bitmaps from Code
- Windows Phone 7 : Image and ImageSource
- Windows Phone 7 : Images Via the Web
- Windows Phone 7 : Customizing Your E-Mail Signature
- Windows Phone 7 : Managing Mail Folders
 
 
Most View
- Performing SharePoint 2010 Installations (part 1) - SharePoint 2010 Standalone Installation
- Microsoft Exchange Server 2003: Configuring Recipient Objects (part 2) - Managing Mailboxes
- Windows7: Managing Network Connections (part 5) - Using a Network Connection to Wake Up a Sleeping Computer
- Windows Server 2008 : Schedule Regular Full Server Backups of a Domain Controller by Using the Windows Interface
- Windows 7: Managing Wireless Network Connections (part 3) - Reordering Wireless Connections
- Microsoft SQL Server 2008 R2 : Monitoring Replication (part 1) - Replication Monitoring SQL Statements
- Programming Windows Phone 7 : The Phone’s Photo Library
- SQL Server Programmability Objects
- Windows Server 2008 : Configuring FTP (part 12) - Managing FTP Site Settings
- SharePoint 2010 : Authoring Pages - Create a New Page (part 1)
Top 10
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 3) - Configuring Recipient Filtering
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 2)
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 1)
- Implementing Edge Services for an Exchange Server 2007 Environment : Installing and Configuring the Edge Transport Server Components
- What's New in SharePoint 2013 (part 7) - BCS
- What's New in SharePoint 2013 (part 6) - SEARCH
- What's New in SharePoint 2013 (part 6) - WEB CONTENT MANAGEMENT
- What's New in SharePoint 2013 (part 5) - ENTERPRISE CONTENT MANAGEMENT
- What's New in SharePoint 2013 (part 4) - WORKFLOWS
- What's New in SharePoint 2013 (part 3) - REMOTE EVENTS