Simon (darkside) Jackson b42cde02ed Rebase commit after moving out ZIP's 5 년 전
..
readme.htm b42cde02ed Rebase commit after moving out ZIP's 5 년 전

readme.htm







Spacewar Starter Kit




This topic contains the following sections.




Introduction




This Microsoft® XNA™ Game Studio 2.0 Spacewar Starter Kit is a complete starship combat game. The project comes ready to compile and run, and is easy to customize with only a little extra C# programming. The Extending Spacewar section contains a list of some customizations you might make. You are also free to use the source code as the basis for your own XNA Game Studio game projects, and to share your work with others.



Spacewar is provided in XNA Game Studio 2.0 for your enjoyment and modification. The game comes in two versions: Retro and Evolved. The Retro version is inspired by the first implementation of Spacewar, developed by Stephen Russell, Peter Samson, and Dan Edwards in 1962 for the DEC PDP-1; the Evolved version features similar gameplay, but with 3D models and effects.



Note
This documentation assumes that you have a basic knowledge of programming concepts and the Visual C# environment. You can learn more about these topics in the product documentation by clicking one of the Help menu items, or by positioning the mouse cursor on language keywords or user interface elements such as windows or dialog boxes, and then pressing the F1 key.




Goals



This starter kit provides a complete XNA Game Studio 2.0 game, including source code and game content such as 3D models, textures, and sounds. This starter kit documentation describes the Spacewar game, and then suggests interesting customizations you can make. The Spacewar starter kit demonstrates:



  • XNA Framework, including the Application Model and Content Pipeline

  • Game graphics, audio, and input

  • Game concepts such as collision detection and the game loop

  • C# Language





Getting Started




Creating, Building, and Running a Spacewar Project



You can create multiple Spacewar projects. Each is a complete, stand-alone game that you can build, run, and modify as desired.



To create a new Spacewar project


  1. On the File menu in your version of Visual Studio, click New, and then click Project.

  2. A dialog box will appear with a tree list on the left pane, marked Project Types. Select XNA Game Studio 2.0 underneath the Visual C# node.

  3. A set of available projects will appear in the Templates pane. Select Spacewar Xbox 360 Starter Kit (2.0), and then click OK.


Note
The starter kit may take a minute or two to load.




To build and run the Spacewar project



  1. Press the F5 key or, on the Debug menu, click Start Debugging.

  2. The project will build and then run within the debugger.



Note

The project may take several minutes to build before it can be launched. To see build progress during the build, display the output window (from the View menu, click Output) before starting the build.




To build the project without running it



  1. Press the F6 key or, on the Build menu, click Build Solution.

  2. The project will build without running.






When Spacewar starts, it displays the main screen where you can choose to play the Retro or Evolved versions of the game, or see controller Info.




Playing Spacewar



Spacewar can be played by one or two players. Players first choose a ship type and color; then, the battle begins. The goal in Spacewar is to use your ship's weapon to destroy your opponent's ship, but beware! Your opponent's weapon is not the only threat: You must also avoid the gravitational pull of the sun or be destroyed!



You score points by destroying your opponent. After each round of play, the cash you earned from annihilating your enemy can be used to buy new weapons for the next round.



Spacewar Controls



You can use a keyboard or Xbox 360 controller to play Spacewar. The controls are mapped as follows:







































Action Controller Keyboard P1 Keyboard P2
Select ship type, color, and weapon D-pad A, D, W, S arrow keys or keypad arrows
Fire weapon Right trigger or A V keypad 7, keypad ., HOME, or DELETE
Rotate ship, forward and reverse thrust Left thumbstick A, D, W, S arrow keys or keypad arrows
Hyperspace warp Left trigger or B G keypad 1, keypad 0, END, or INSERT
Pause Back Left SHIFT Right SHIFT





























Button Keyboard P1 Keyboard P2
A V HOME or keypad 7
B G END or keypad 1
X F PAGE UP or keypad 9
Y T PAGE DOWN or keypad 3






Extending Spacewar



The Spacewar starter kit contains many models, textures, and sounds that you can experiment with to make changes to the graphics and audio in the game. From making a few small changes in Spacewar, to significantly altering gameplay and graphics, to creating your own game using some of Spacewar's content, algorithms, or sample code, how you use this starter kit is entirely up to you.



Here a just a few examples of the types of changes you can make to Spacewar.





  • Create or modify 3D models.


    You can add new 3D models that you create, modify, or download. XNA Game Studio 2.0 accepts geometry and model data in the DirectX X file format (.x) and Autodesk FBX format (.fbx). Most 3D design tools will export to one of these two formats.


    For information about adding and using models, see the Content Pipeline Overviews and 3D Graphics topics in the documentation.




  • Create or modify textures.


    The textures associated with models can be changed. XNA Game Studio 2.0 supports the following file formats: .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, and .tga.


    For information about adding and using textures, see the Content Pipeline Overviews topic in the documentation.




  • Create or modify shaders and effects.


    Spacewar comes with several effects, from the aptly named simple.fx to the more complex ship.fx. Shaders and effects are powerful ways to control and enhance the lighting, materials, and textures of your models. With a little bit of work and experimentation you can create truly amazing effects.


    For information about shaders and effects, see the 3D Graphics Overview and How to: Create and Apply Custom Effects topics in the documentation.



  • Change ship performance: speed, rotation, and thrust.

  • Change weapon characteristics: speed, damage, and reload time.

  • Change game rules: earned money, turn length, and victory conditions.

  • Without changing any code, you can modify the settings.xml file to change several game parameters including lighting, speed, gravity, thrust, as well as the keyboard mappings that the game uses.

  • Make the Sun a "third player." When the Sun destroys your ship, the points go to the Sun rather than your opponent. Perhaps the Sun could win, or upgrade.

  • Change the shaders used by the different models, for strange and unique effects.




The Getting Started with XNA Game Studio section of the documentation contains some excellent walthroughs that show you how to use sprites, 3D graphics, models, textures, input, audio, and more.



Example Change



Here's an example modification that you can make to Spacewar.



Rogue Asteroid!



Make an asteroid available as one of the ship choices.




  1. In the Evolved\EvolvedShape.cs file, change the p1_saucer ship mesh to the asteroid2 mesh:


    C# 
    private static string[,] shipMesh = new string[,]
    {
    {
    @"models\p1_pencil",
    @"models\asteroid2", // @"models\p1_saucer",
    @"models\p1_wedge",
    },



  2. In the same file, change the texture used by that ship mesh (or you can keep the original ship texture for a truly evolved asteroid):


    C# 
    private static string[,] shipDiffuse = new string[,] 
    {
    {
    @"textures\pencil_p1_diff_v{0}",
    @"textures\asteroid2", // @"textures\saucer_p1_diff_v{0}",
    @"textures\wedge_p1_diff_v{0}",
    },



That's all there is to it. Player one's second ship choice (the saucer) is now rendered as an asteroid. These ship models and textures are loaded in EvolvedShape.Render using the ContentManager.Load method:


C# 
model = SpacewarGame.ContentManager.Load<Model>(SpacewarGame.Settings.MediaPath + shipMesh[(int)player, shapeNumber]);
texture = SpacewarGame.ContentManager.Load<Texture2D>(SpacewarGame.Settings.MediaPath + String.Format(shipDiffuse[(int)player, shapeNumber], (skinNumber + 1)));

Some possible further Rogue Asteroid modifications:



  • Change the 2D ship shown on the ship selector screen to match the asteroid. (You'll need to edit the textures\ship_select_FINAL.tga texture.)

  • Change the rotation axis of the asteroid so that it rotates about its short axis instead of its long axis.

  • Change the engine thrust offset, characteristics, or color. The Ship.cs file performs the engine thrust calculations and rendering (look at the Update and Render methods).

  • Change the materials or effect used by the rogue asteroid.

  • Change the weapon power and speed of the asteroid.