You are previewing XNA® 3.1 Game Development for Teens: Game Development on the PC, Xbox 360®, and Zune® Player.
O'Reilly logo
XNA® 3.1 Game Development for Teens: Game Development on the PC, Xbox 360®, and Zune® Player

Book Description

XNA 3.0 GAME DEVELOPMENT FOR TEENS is a complete guide to entry level programming and computer game development using XNA 3.0 and the Visual C# 2008 Express programming language for beginners. This book shows readers how to create and execute computer games on their PC, and then how to port their PC games over to their Xbox 360 or Zune player. This book is for anyone looking to begin creating their own computer games with XNA 3.0 and Visual C# 2008 Express.

Table of Contents

  1. Copyright
    1. Dedication
  2. Acknowledgments
  3. About the Author
  4. Introduction
    1. Why XNA 3.1?
    2. Who Should Read This Book?
    3. What You Need to Begin
    4. Conventions Used in This Book
    5. Companion Website Downloads
  5. I. XNA Development Basics
    1. 1. Introducing Microsoft XNA Game Studio 3.1
      1. The Computer Gaming Industry
      2. Getting to Know Microsoft XNA Game Studio 3.1
        1. XNA 3.1 Uncovered
          1. The Visual Studio Express IDE
          2. XNA Framework
          3. DirectX
          4. C#
          5. The .NET Framework
      3. Computer Game Development
        1. Zune
        2. Xbox 360
      4. Getting Started with XNA 3.1
        1. Downloading and Installing Microsoft Visual C# 2008 Express onto Your Computer
        2. Installing Microsoft XNA Game Studio 3.1 onto Your Computer
        3. Creating an Xbox Live Account
      5. Connecting Your Xbox 360 and Zune to Your Computer
        1. Connecting Your Xbox 360 to Your Internet Router
        2. Setting Up a Connection with Your Computer
        3. Connecting Your Zune to Your Computer
      6. Joining the XNA Creators Club
      7. Summary
    2. 2. Getting Started
      1. Getting to Know the Visual Studio 2008 Express IDE
        1. Navigating IDE Menus
        2. Working with Toolbars
        3. Getting to Know the Code Editor
          1. Pre-written Program Code
          2. Color Coding, Automatic Indentation, and Spacing
          3. Taking Advantage of “IntelliSense Everywhere”
        4. Introducing the Solution Explorer
        5. Understanding the Properties Window
        6. Working with the Error List Window
      2. Summary
    3. 3. Creating Your First XNA Application
      1. Classes, Objects, Methods, and Variables
      2. Creating a Simple XNA Application
        1. Creating a New Project
        2. Executing Your New Application
        3. Halting Application Execution
      3. Examining Program Organization and Structure
        1. Examining the Program.cs Program
        2. Examining the Game1.cs Program
          1. Using Directive Statements to Reference Namespaces
          2. Defining a Local Namespace and Class
          3. Defining with Data Members
          4. Examining Method Members
      4. Dissecting the Game1.cs Program
      5. Summary
  6. II. Learning How to Program with Visual C# Studio Express 2008
    1. 4. Working with Data, Values, and Variables
      1. Introducing C#
        1. C# Programs Are Compiled
        2. C# Is an Object-Oriented Programming Language
      2. Documenting Your Program Code
      3. Working with Different Types of Values
      4. Storing and Retrieving Game Data
      5. Defining C# Variables
        1. Naming Variables
        2. Variable Scope
      6. Storing Data That Does Not Change
      7. Managing Collections of Data
        1. Accessing Array Contents
        2. Using a Loop to Process an Array
        3. Creating Dense Arrays
      8. Manipulating Data
        1. Performing Calculations
        2. Assigning Variable Values
        3. Comparing Variable Values
      9. C# Keywords
      10. Summary
    2. 5. Conditional Logic and Loops
      1. Creating an XNA Template Application
      2. Analyzing Data and Making Decisions
        1. Implementing Conditional Logic Using the if Statement
        2. Using Multiline if Statements
        3. Specifying Alternative Conditions
        4. Evaluating Additional Conditions
        5. Nesting Multiple if Statements
        6. Implementing Conditional Logic Using the switch Statement
      3. Processing Data Efficiently with Loops
        1. Using the for Loop
        2. Using the while Loop
        3. Using the do Loop
        4. Using the foreach Loop
        5. Altering Normal Loop Execution
      4. Summary
    3. 6. Objects, Classes, and Methods
      1. A Deeper Look at the Inner Workings of XNA Applications
        1. The System Name Space
        2. Namespaces
        3. The Program Class
        4. Methods
        5. Garbage Collection
        6. Game Execution
      2. Object-Oriented Programming
      3. Important OOP Terms You Need to Know
        1. Abstraction
        2. Encapsulation
        3. Inheritance
        4. Polymorphism
      4. Defining Your Own Classes and Objects
        1. Creating a New Class
        2. Understanding Data Members
        3. Setting Up Class Properties
        4. Instantiating Objects
        5. Adding Methods to Classes
        6. Overloading Methods
        7. Inheriting from Another Class
      5. Structures
      6. Summary
  7. III. Game Development Basics
    1. 7. Collecting User Input
      1. Using Game Input
        1. Collecting Player Input
        2. Platform-Supported Controllers
      2. Collecting Gamepad Input
        1. Gamepad Buttons
        2. Thumbstick Controls
        3. The Dpad
        4. Vibrating the Gamepad
      3. Collecting and Processing Keyboard Input
      4. Collecting Mouse Input
      5. Interacting with Zune Users
      6. Creating Multi-Platform Games
      7. Creating the Control Testing Application
        1. Adding a SpriteFont to Display Test Output
        2. Defining Game World Data
        3. Application Initialization
        4. Keeping the Game Updated
          1. Retrieving Input Device State Data
          2. Managing Application Termination
          3. Interacting with the Gamepad
          4. Collecting and Reporting Mouse Data
          5. Processing Keyboard Input
        5. Displaying Output
      8. Summary
    2. 8. Working with Images
      1. Graphics Can Make or Break Your Games
      2. Adding Graphics to Your XNA Games
      3. Managing Game Content
        1. Adding Graphic Content to Your XNA Projects
        2. Defining Variables for Your Assets
        3. Loading Game Assets
        4. Using the Rectangle Structure to Manage the Placement of Graphics
        5. Working with Assets
      4. Bringing It All Together
        1. Creating a Picture Viewer
        2. Creating an Electronic Picture Viewer
      5. Summary
    3. 9. Adding Sound Effects and Background Music
      1. Adding Audio to Your Games
        1. Adding Audio Files to Your XNA Applications
        2. Defining and Locating Sound Resources
        3. Controlling Sound Playback
      2. Supported Audio File Formats
      3. Adding Sound Effects to Projects
      4. Exercising Additional Control of Audio Playback
      5. Setting the Mood with Background Music
        1. Working with the Computer’s Media Player
          1. Loading a .wma or .mp3 File
          2. Associating Variables with Your Audio Files
          3. Loading Audio Files
          4. Playing Background Music
        2. Creating the Music Machine Application
          1. Importing the Audio Files
          2. Importing the Graphic Files
          3. Importing and Configuring Fonts
          4. Time to Start Coding
      6. Summary
  8. IV. Building Games for the PC, Xbox 360, and Zune
    1. 10. Creating Your Own Arcade Game
      1. Key Features Found in Most Computer Games
        1. Controlling a Game’s State
        2. Setting Sprite Size and Shape
        3. Moving Things Around
        4. Detecting When Sprites Move Off the Screen
        5. Managing Collisions
          1. Bounded Sprites
          2. Detecting When Collisions Occur
        6. Going Full Screen
        7. Dealing with Display Overscan
      2. Creating the XNA Breakout Game
        1. Step 1—Creating a New Project
          1. Importing the Audio Files
          2. Importing the Graphic Files
          3. Importing and Configuring Fonts
        2. Step 2—Defining Game World Data
        3. Step 3—Setting Screen Resolution and Full-Screen Mode
        4. Step 4—Initializing Game Play
        5. Step 5—Loading Game Content
        6. Step 6—Updating Game Play
        7. Step 7—Drawing the Game
        8. Step 8—Configuring the Screen
        9. Step 9—Configuring the Ball and Paddle
        10. Step 10—Starting Game Play
        11. Step 11—Processing Player Input
        12. Step 12—Managing Ball Movement
        13. Step 13—Keeping Track of the Bricks
        14. Step 14—Redisplaying the Bricks
        15. Step 15—Displaying the Splash Screen
      3. Summary
    2. 11. Porting Your Games to the Xbox 360 and Zune Player
      1. Deploying Your XNA Games to Other Platforms
        1. Setting Up Connections
        2. Developing Cross-Platform Games
          1. Creating a Platform-Specific Game
          2. Converting a Windows Game to Another Platform
        3. Platform Issues to Consider
          1. Differences in Input
          2. Audio Compatibility
          3. Handling Different Screen Sizes and Resolution
        4. Conditional Compilation
      2. Submitting Your Games to the XNA Creators Club
      3. Learning How to Handle Errors
        1. Syntax Errors
        2. Logical Errors
        3. Runtime Errors
      4. Using Breakpoints to Control Application Execution
        1. Establishing Breakpoints
        2. Stepping through Application Execution
        3. Edit and Continue
      5. Developing Exception Handlers
        1. Structured Exception Handlers
      6. Summary
  9. V. Appendices
    1. A. What’s on the Companion Website?
      1. Downloading the Book’s Source Code
    2. B. What’s Next?
      1. Locating XNA Resources Online
        1. The XNA Developer Center Website
        2. The Wikipedia Microsoft XNA Page
        3. The xnPlay Website
        4. The XBLA and XNA Ratings Page
        5. The XNA Creators Club Online Website
        6. The XNA Team Blog
        7. The Forums Located at the Creators Club Online
      2. Locating Additional Information on Microsoft Visual C# 2008 Express
        1. The Visual C# Development Center
        2. The Visual C# 2008 Express Edition Page
        3. The Wikipedia C Sharp Page
      3. Other Game Development Resources
      4. The Xbox 360
        1. The Xbox Website
        2. Wikipedia’s Xbox 360 Page
      5. The Zune Portable Media Player
        1. The Zune Website
        2. Wikipedia’s Zune Page
      6. The Author’s Website
  10. Glossary