XNA* game

Download this app from here.

XNA Game Sample Application
This sample application will help you get hands on experience with multi-threading using Intel’s dual core processors.


Environment Note:
In order to use this sample, you will need a working test or development environment. This environment can be obtained by:


1) Installing Visual C# Express 2005 on a standalone machine.
2) Installing XNA Game Studio Express Beta on a standalone machine. Regardless of environment, you should be able to peruse the contents of this sample application and be able to easily discern what changes are needed in order to implement multi-threading into your own gaming applications. Setup:
Once you have a suitable execution and testing environment,

  • Copy and paste the  folder MultiThreadedXNAGame containing this sample application on to a computer which has Visual C# Express installed.
  • Open the MultiThreadedXNAGame.sln solution in Visual C# Express as an Existing Project.

Once you have completed the setup process, you can begin debugging this sample application by pressing F5, at which point the main form will load. Once this form is loaded, you will be able to more easily examine how the examples provided in this sample application operate. In this sample application, multi-threaded sections are highlighted in two areas:
Loading:  Before the textures can be written to the screen, the graphic files must be loaded into the texture objects.  In this sample, the textures can be loaded in a single-threaded mode (Fig. 1) or a multi-threaded mode(Fig. 2).  This occurs in the LoadResources method of the application.

Figure 1 Single-threaded Loading of Textures


Figure 2 Multi-threaded Loading of Textures

Updating: This inherent method is called each time the screen refreshes.  To simulate multiple users entering the game, this application fabricates a large number of users being added and updated.  In the updating section, each user's position and speed is updated.  By multi-threading this section, users will experience better user interface responsiveness.

Figure 3 Single-threaded Updating of the people on the screen

Figure 4 Multi-threaded Updating of the people on the screen

Exploring the Samples: To observe multi-threading functionality in action, open and run the application. The game is by default in multi-threaded mode.  You can change the game into single-threaded mode by hitting the "I" key.  To switch back into multi-threaded mode, you can hit the "M" key.


You also have control over the blue person and move them in any direction.  Below is the key mapping to move the blue person:


"E" key = move up
"X" key = move down
"D" key = move left
"S" key = move right
"R" key = move North/East
"W" key = move North/West
"Z" key = move South/West
"C" key = move South/East


You can also move the yellow person left and right.  Below is the key mapping to move the yellow person:


Left arrow key = move left
Right arrow key = move right


If you want to simulate creating a new person, click the "N" key and that will create the orange person.


You can also simulate collisions.  The purple moves around the screen randomly, but will bounce off of the blue person as well as the yellow and green person.


To exit the application, you can select the Debug | Stopping Debugging menu command in Visual C# Express or you can hit the "Esc" key in the game.
How to Extend this application: This application serves a base application . To see other resources related to this sample, click on the links below:

Download this app from here.


Para obter informações mais completas sobre otimizações do compilador, consulte nosso aviso de otimização.