Learning XNA 4.0

Book description

Want to develop games for Xbox 360 and Windows Phone 7? This hands-on book will get you started with Microsoft's XNA 4.0 development framework right away -- even if you have no experience developing games. Although XNA includes several key concepts that can be difficult for beginning web developers to grasp, Learning XNA 4.0 shortens the learning curve by walking you through the framework in a clear and understandable step-by-step format.

Each chapter offers a self-contained lesson with illustrations and annotated examples, along with exercises and review questions to help you test your understanding and practice new skills as you go. Once you've finished this book, you'll know how to develop your own sophisticated games from start to finish.

  • Learn game development from 2D animation to 3D cameras and effects
  • Delve into high-level shader language (HLSL) and introductory artificial intelligence concepts
  • Build three complete, exciting games using 2D, 3D, and multiplayer techniques
  • Develop for and deploy your games to the Xbox 360 and Windows Phone 7

Publisher resources

View/Submit Errata

Table of contents

  1. Dedication
  2. A Note Regarding Supplemental Files
  3. Preface
    1. Who This Book Is For
    2. How This Book Is Organized
    3. Support
    4. Conventions Used in This Book
    5. Using Code Examples
    6. We’d Like to Hear from You
    7. Safari® Books Online
    8. Acknowledgments
  4. 1. What’s New in XNA 4.0?
    1. Revised Project Folder Structure
    2. Develop Games for Windows Phone 7 Series
    3. Graphics Profiles
    4. Configurable Effects
    5. Built-in State Objects
    6. Scalars and Orientation
    7. Revised Input API
    8. Additional Audio API
    9. Music and Picture Enumeration and Video Playback
    10. Modified and Added Classes and Methods
    11. Test Your Knowledge: Quiz
  5. 2. Getting Started
    1. System Requirements
    2. Additional Resources
    3. Installation
    4. Creating Your First XNA Application
    5. What You Just Did
    6. Summary
    7. Test Your Knowledge: Quiz
  6. 3. Fun with Sprites
    1. A Look Behind the Scenes
    2. Game Development Versus Polling
    3. Modifying Your Game
    4. Adding a Sprite to Your Project
    5. Loading and Drawing Your Sprite
    6. Transparency and Other Options
    7. Layer Depth
    8. Let’s Move
    9. Animation
    10. Adjusting the Framerate
    11. Adjusting the Animation Speed
    12. What You Just Did
    13. Summary
    14. Test Your Knowledge: Quiz
    15. Test Your Knowledge: Exercise
  7. 4. User Input and Collision Detection
    1. More Sprites
    2. Keyboard Input
    3. Mouse Input
    4. Gamepad Input
    5. Keeping the Sprite in the Game Window
    6. Collision Detection
    7. What You Just Did
    8. Summary
    9. Test Your Knowledge: Quiz
    10. Test Your Knowledge: Exercise
  8. 5. Applying Some Object-Oriented Design
    1. Designing Your Classes
    2. Creating a Sprite Class
    3. Creating a User-Controlled Sprite Class
    4. Creating an Automated Sprite Class
    5. Game Components
    6. Coding the SpriteManager
    7. Cleaning Up
    8. Making Them Move
    9. What You Just Did
    10. Summary
    11. Test Your Knowledge: Quiz
    12. Test Your Knowledge: Exercise
  9. 6. Sound Effects and Audio
    1. Using XACT
    2. Implementing XACT Audio Files in Code
    3. Using the Simplified API for Sound and Audio
    4. Adding More Sound to Your Game
    5. What You Just Did
    6. Summary
    7. Test Your Knowledge: Quiz
    8. Test Your Knowledge: Exercise
  10. 7. Basic Artificial Intelligence
    1. The Turing Test
    2. Creating Sprites at Random Intervals
    3. Randomly Spawning Sprites
    4. Irrelevant Objects
    5. Creating a Chasing Sprite
    6. Creating an Evading Sprite
    7. What You Just Did
    8. Summary
    9. Test Your Knowledge: Quiz
    10. Test Your Knowledge: Exercise
  11. 8. Putting It All Together
    1. Drawing 2D Text
    2. Randomly Generating Different Sprite Types
    3. Adding Some Variety to Your Sprites
    4. Adding a Background Image
    5. Game Scoring
    6. Game States
    7. Enabling/Disabling GameComponents
    8. Game-Over Logic and the Game-Over Screen
    9. Fine-Tuning Gameplay
    10. Creating Power-Ups
    11. What You Just Did
    12. Summary
    13. Test Your Knowledge: Quiz
    14. Test Your Knowledge: Exercise
  12. 9. 3D Game Development
    1. Coordinate Systems
    2. Cameras
    3. Creating a 3D Camera
    4. Drawing Primitives
    5. Matrix Multiplication
    6. Movement and Rotation
    7. Backface Culling
    8. More on Rotations
    9. Even More Rotations
    10. Primitive Types
    11. Applying Textures
    12. What You Just Did
    13. Summary
    14. Test Your Knowledge: Quiz
    15. Test Your Knowledge: Exercise
  13. 10. 3D Models
    1. Using 3D Models
    2. Setting Up the Project
    3. Adding a Model to Your Project
    4. Drawing a Model Using a BasicModel Class
    5. Adding a Model Manager
    6. Rotating Your Model
    7. What You Just Did
    8. Summary
    9. Test Your Knowledge: Quiz
    10. Test Your Knowledge: Exercise
  14. 11. Creating a First-Person Camera
    1. Components of a Moving 3D Camera
    2. Moving in a First-Person Camera
    3. Rotations in a First-Person Camera
      1. Rotating a Camera in a Yaw
      2. Rotating a Camera in a Roll
      3. Rotating a Camera in a Pitch
    4. Coding the Camera for the 3D Game
    5. What You Just Did
    6. Summary
    7. Test Your Knowledge: Quiz
    8. Test Your Knowledge: Exercise
  15. 12. 3D Collision Detection and Shooting
    1. Creating a Moving Enemy
    2. Adding Some Game Logic
    3. Firing Shots
    4. 3D Collision Detection and Bounding Spheres
    5. Adding a Crosshair
    6. Adding Sound
    7. What You Just Did
    8. Summary
    9. Test Your Knowledge: Quiz
    10. Test Your Knowledge: Exercise
  16. 13. HLSL Basics
    1. HLSL Syntax
    2. Dissecting a Sample HLSL Effect File
    3. Applying an HLSL Effect in C#
    4. Applying HLSL Using Textures
    5. HLSL Effects: Creating a Negative
    6. HLSL Effects: Blur
    7. HLSL Effects: Grayscale
    8. What You Just Did
    9. Summary
    10. Test Your Knowledge: Quiz
    11. Test Your Knowledge: Exercise
  17. 14. Particle Systems
    1. Creating a Particle Engine
    2. Adding a Particle Effect File
    3. Adding Your Particle Engine to Your Game
    4. Adding a Starfield
    5. What You Just Did
    6. Summary
    7. Test Your Knowledge: Quiz
  18. 15. Wrapping Up Your 3D Game
    1. Adding a Splash Screen Game Component
    2. Keeping Score
    3. Adding a Power-Up
    4. What You Just Did
    5. Test Your Knowledge: Exercise
  19. 16. Deploying to the Xbox 360
    1. Adding an Xbox 360 Device
    2. Converting a Project to Run on the Xbox 360
    3. Supporting Gamepad Input
    4. Deploying to the Xbox 360
    5. Xbox 360 Display Settings
    6. The Title Safe Region
    7. What You Just Did
    8. Summary
    9. Test Your Knowledge: Quiz
  20. 17. Developing for Windows Phone 7
    1. Setting Up Your Windows Phone 7 Device
      1. Registering for a Developer Account
      2. Registering Your Windows Phone 7 Device
      3. Unlocking Your Phone
    2. Creating a Windows Phone 7 Project
    3. Resources
    4. Digging In
      1. Screen Rotation and Resolution
      2. More Model Classes
    5. Adding a ModelManager
    6. Finishing Details
    7. What You Just Did
    8. Summary
    9. Test Your Knowledge: Quiz
  21. 18. Multiplayer Games
    1. Split-Screen Functionality
    2. Network Game Development
    3. Network Configurations
    4. Writing an XNA Network Game
    5. Modifying the Sprite Class
    6. Modifying the UserControlledSprite Class
    7. Coding Your Game1 Class
    8. Adding Update Code
      1. Updating While in the SignIn Game State
      2. Updating While in the FindSession Game State
      3. Updating While in the CreateSession GameState
      4. Updating While in the Start Game State
        1. When the local player starts the game
        2. When the remote player starts the game
      5. Updating While in the InGame Game State
      6. Updating While in the GameOver Game State
    9. Adding Draw Code
    10. Adding Biohazard Bombs of Insanity!
    11. What You Just Did
    12. Summary
    13. Test Your Knowledge: Quiz
  22. A. Answers to Quizzes and Exercises
    1. Chapter 1: What’s New in XNA 4.0?
      1. Quiz Answers
    2. Chapter 2: Getting Started
      1. Quiz Answers
    3. Chapter 3: Fun with Sprites
      1. Quiz Answers
      2. Exercise Answer
    4. Chapter 4: User Input and Collision Detection
      1. Quiz Answers
      2. Exercise Answer
    5. Chapter 5: Applying Some Object-Oriented Design
      1. Quiz Answers
      2. Exercise Answer
    6. Chapter 6: Sound Effects and Audio
      1. Quiz Answers
      2. Exercise Answer
    7. Chapter 7: Basic Artificial Intelligence
      1. Quiz Answers
      2. Exercise Answer
    8. Chapter 8: Putting It All Together
      1. Quiz Answers
      2. Exercise Answer
    9. Chapter 9: 3D Game Development
      1. Quiz Answers
      2. Exercise Answer
    10. Chapter 10: 3D Models
      1. Quiz Answers
      2. Exercise Answer
    11. Chapter 11: Creating a First-Person Camera
      1. Quiz Answers
      2. Exercise Answer
    12. Chapter 12: 3D Collision Detection and Shooting
      1. Quiz Answers
      2. Exercise Answer
    13. Chapter 13: HLSL Basics
      1. Quiz Answers
      2. Exercise Answer
    14. Chapter 14: Particle Systems
      1. Quiz Answers
    15. Chapter 15: Wrapping Up Your 3D Game
      1. Exercise Answer
    16. Chapter 16: Deploying to the Xbox 360
      1. Quiz Answers
    17. Chapter 17: Developing for Windows Phone 7
      1. Quiz Answers
    18. Chapter 18: Multiplayer Games
      1. Quiz Answers
  23. Index
  24. About the Author
  25. Colophon
  26. Copyright

Product information

  • Title: Learning XNA 4.0
  • Author(s): Aaron Reed
  • Release date: December 2010
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449394622