You are previewing XNA 4 3D Game Development by Example Beginner's Guide.
O'Reilly logo
XNA 4 3D Game Development by Example Beginner's Guide

Book Description

Create action-packed 3D games with the microsoft XNA Framework.

  • Learn the structure of a 3D world and how to implement a variety of 3D techniques including terrain generation and 3D model rendering.

  • Build three different types of 3D games step-by-step, including a first-person maze game, a battlefield tank game, and a 3D sidescrolling action game on the surface of Mars.

  • Learn to utilize High Level Shader Language (HLSL) to add lighting and multi-texturing effects to your 3D scenes.

In Detail

Move beyond the world of flat 2D-based game development and discover how to create your own exciting 3D games with Microsoft XNA 4.0. Create a 3D maze, fire shells at enemy tanks, and drive a rover on the surface of Mars while being attacked by alien saucers.

"XNA 4 3D Game Development by Example: Beginner's Guide" takes you step-by-step through the creation of three different 3D video games with Microsoft XNA 4.0. Learn by doing as you explore the worlds of 3D graphics and game design.

This book takes a step-by-step approach to building 3D games with Microsoft XNA, describing each section of code in depth and explaining the topics and concepts covered in detail.

From the basics of a 3D camera system to an introduction to writing DirectX shader code, the games in this book cover a wide variety of both 3D graphics and game design topics. Generate random mazes, load and animate 3D models, create particle-based explosions, and combine 2D and 3D techniques to build a user interface.

"XNA 4 3D Game Development by Example: Beginner's Guide" will give you the knowledge to bring your own 3D game creations to life.

Table of Contents

  1. XNA 4 3D Game Development by Example Beginner's Guide
    1. Table of Contents
    2. XNA 4 3D Game Development by Example Beginner's Guide
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
        3. Instant Updates on New Packt Books
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Time for action – heading
        1. What just happened?
        2. Pop quiz – heading
        3. Have a go hero – heading
      6. Reader feedback
      7. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Introduction to XNA
      1. System requirements
      2. Installing the Windows Phone SDK
      3. Time for action – installing Windows Phone SDK
        1. What just happened?
      4. Speller – Our first XNA game
      5. Time for action – creating an XNA project
        1. What just happened?
      6. Managing content
      7. Time for action – creating content assets
        1. What just happened?
      8. Member variables
      9. Time for action – declaring new member variables
        1. What just happened?
      10. The Game1 constructor
      11. Initialization
      12. Time for action – customizing the Initialize() method
        1. What just happened?
      13. Loading content
      14. Time for action – creating a square texture
        1. What just happened?
      15. Updating
      16. Time for action – customizing the Update() method
        1. What just happened?
      17. The Draw() method
      18. Time for action – drawing Speller
        1. What just happened?
      19. Helper methods
      20. Time for action – words and letters
        1. What just happened?
      21. Time for action – completing the Speller project
        1. What just happened?
        2. Have a go hero
      22. Summary
    9. 2. Cube Chaser – A Flat 3D World
      1. Designing the game
        1. 3D coordinates
      2. Creating the project
      3. Time for action – creating the Cube Chaser project
        1. What just happened?
      4. Our view of the world
      5. Time for action – beginning the Camera class
        1. What just happened?
      6. The Projection matrix
      7. Looking at something
      8. Time for action – implementing a look-at point
        1. What just happened?
      9. The View matrix
      10. Time for action – the View matrix
        1. What just happened?
      11. From the ground up
      12. Time for action – creating the Maze classes
        1. What just happened?
      13. Drawing the floor
      14. Time for action – drawing the floor
        1. What just happened?
      15. Moving around
      16. Time for action – expanding the Camera
        1. What just happened?
      17. Time for action – letting the player move
        1. What just happened?
      18. Summary
    10. 3. Cube Chaser – It's A-Mazing!
      1. Maze generation
      2. Time for action – defining a MazeCell
        1. What just happened?
      3. Time for action – generating the Maze class
        1. What just happened?
      4. Constructing the walls
      5. Time for action – building walls
        1. What just happened?
      6. Time for action – drawing the walls
        1. What just happened?
      7. Solid walls
      8. Time for action – bouncing off the walls
        1. What just happened?
        2. Have a go hero
      9. Summary
    11. 4. Cube Chaser – Finding Your Way
      1. The cube
      2. Time for action – placing the cube
        1. What just happened?
        2. Rotating the cube
      3. Time for action – rotating the cube
        1. What just happened?
      4. Matrices – big scary math things?
        1. The translation matrix
        2. The rotation matrix
        3. The scale matrix
        4. Combining matrices
        5. What does it all mean?
      5. Positioning the cube
      6. Time for action – randomly positioning the cube
        1. What just happened?
      7. Catching the cube
      8. Time for action – catching the cube
        1. What just happened?
        2. Have a go hero!
      9. Summary
    12. 5. Tank Battles – A War-torn Land
      1. Creating the project
      2. Time for action – creating the Tank Battles project
        1. What just happened?
      3. An arc-ball camera
      4. Time for action – the ArcBallCamera class – part 1
        1. What just happened?
      5. Time for action – finishing the ArcBallCamera class
        1. What just happened?
      6. Building the playfield
        1. Height maps
        2. Generating the terrain
      7. Time for action – generating the terrain
        1. What just happened?
          1. Height data
      8. Time for action – adding the ReadHeightMap() method
        1. What just happened?
          1. Building vertices
      9. Time for action – adding the BuildVertexBuffer() method
        1. What just happened?
          1. Building the indices
      10. Time for action – the buildIndexBuffer() method
        1. What just happened?
      11. Let's see the terrain already!
      12. Time for action – drawing the terrain
        1. What just happened?
      13. Adding texture – a gentle introduction to HLSL
        1. Declaring variables
      14. Time for action – HLSL declarations
        1. What just happened?
        2. The vertex shader structures
      15. Time for action – Vertex Shader Input and Output definition
        1. What just happened?
        2. The vertex shader
      16. Time for action – the vertex shader
        1. What just happened?
        2. The pixel shader
      17. Time for action – the pixel shader
        1. What just happened?
      18. Time for action – utilizing Terrain.fx
        1. What just happened?
      19. Moving the camera
      20. Time for action – moving the camera with the mouse
        1. What just happened?
      21. Summary
    13. 6. Tank Battles – The Big Guns
      1. Adding the tank model
      2. Time for action – adding the tank model
        1. What just happened?
      3. Building tanks
      4. Time for action – building the Tank class
        1. What just happened?
        2. Bringing things down to earth
      5. Time for action – terrain heights
        1. What just happened?
        2. Animating the tank
      6. Time for action – tank animation
        1. What just happened?
        2. The combatants
      7. Time for action – positioning tanks
        1. What just happened?
      8. Summary
    14. 7. Tank Battles – Shooting Things
      1. Interface components
        1. The UIWidget class
      2. Time for action – creating the UIWidget class
        1. What just happened?
        2. UITextblocks
      3. Time for action – creating UITextblocks
        1. What just happened?
        2. UIButtons
      4. Time for action – creating buttons
        1. What just happened?
        2. Working with our UI objects
      5. Time for action – adding the UIHelper class
        1. What just happened?
        2. Creating the user interface
      6. Time for action – creating the UI
        1. What just happened?
        2. Responding to interface events
      7. Time for action – responding to events
        1. What just happened?
        2. Firing shots
      8. Time for action – ShotManager-part 1
        1. What just happened?
        2. Particles in 3D
          1. Billboarded particles
      9. Time for action – the Particle class-part 1
        1. What just happened?
      10. Time for action – finishing the Particle class
        1. What just happened?
          1. Managing particles
      11. Time for action – the ParticleManager class
        1. What just happened?
          1. HLSL for our particles
      12. Time for action – building Particles.fx
        1. What just happened?
          1. Adding particles
      13. Time for action – implementing particles
        1. What just happened?
      14. Summary
    15. 8. Tank Battles – Ending the War
      1. Managing game states
      2. Time for action – implementing a title screen
        1. What just happened?
        2. From Playing to GameOver
      3. Time for action – detecting hits
        1. What just happened?
      4. Managing turns
      5. Time for action – managing turns
        1. What just happened?
      6. Visual improvements
        1. Lighting
      7. Time for action – computing normals
        1. What just happened?
          1. Diffuse lighting
      8. Time for action – HLSL for lighting
        1. What just happened?
          1. Ambient lighting
      9. Time for action – using ambient light
        1. What just happened?
        2. Multitexturing
      10. Time for action – multitexturing
        1. What just happened?
        2. Have a go hero!
      11. Summary
    16. 9. Mars Runner
      1. Design of Mars Runner
      2. Getting started with the GSM sample
      3. Time for action – creating the Mars Runner solution
        1. What just happened?
        2. The GameScreen abstract class
        3. Customizing the default ScreenManager screens
      4. Time for action – customizing the BackgroundScreen class
        1. What just happened?
      5. Time for action – updating the menu
        1. What just happened?
        2. Adding a new screen
      6. Time for action – creating the MarsRunnerPlayScreen class
        1. What just happened?
      7. A new camera
      8. Time for action – the stationary camera
        1. What just happened?
      9. Creating the background
      10. Time for action – creating a skybox
        1. What just happened?
      11. Building the Martian surface
        1. Simplified heightmaps
      12. Time for action – beginning the MarsTrack class
        1. What just happened?
      13. Time for action – generating the track
        1. What just happened?
        2. Drawing the track
      14. Time for action – drawing the track
        1. What just happened?
      15. Summary
    17. 10. Mars Runner – Reaching the Finish Line
      1. Abstracting support for 3D models
      2. Time for action – the GameEntity class
        1. What just happened?
      3. Building the rover
      4. Time for action –building the rover
        1. What just happened?
      5. Time for action – accepting user input
        1. What just happened?
      6. Animating the planet
      7. Time for action – moving the world
        1. What just happened?
      8. Animating the rover
      9. Time for action – animating the rover
        1. What just happened?
      10. Crashing into craters
      11. Time for action – detecting craters
        1. What just happened?
      12. Adding an enemy
      13. Time for action – the basic flying saucer
        1. What just happened?
      14. Time for action – flying the saucer
        1. What just happened?
      15. Shots and collisions
      16. Time for action – Shot classes
        1. What just happened?
      17. Time for action – the ShotManager class
        1. What just happened?
        2. Enemy shots
      18. Time for action – enemy shots
        1. What just happened?
      19. Time for action – player shots versus aliens
        1. What just happened?
      20. Time for action – enemy shots versus the rover
        1. What just happened?
      21. Scoring
      22. Time for action – scoring
        1. What just happened?
      23. Time for action – the GameOver screen
        1. What just happened?
      24. Sound effects
      25. Time for action – building the SFXManager class
        1. What just happened?
          1. Triggering sounds
      26. Time for action – playing sound effects
        1. What just happened?
        2. Have a go hero!
      27. Summary
    18. Index