You are previewing Microsoft® XNA® Game Studio 2.0: Learn Programming Now!.
O'Reilly logo
Microsoft® XNA® Game Studio 2.0: Learn Programming Now!

Book Description

Your learn-by-doing introduction to computer programming with Microsoft Visual C# 2005 and XNA Game Studio, the Xbox 360™ development tool. Get how-to instructions for customizing Xbox 360 games—and create your own games now!

Table of Contents

  1. Microsoft® XNA® Game Studio 2.0: Learn Programming Now!
  2. Dedication
  3. A Note Regarding Supplemental Files
  4. Acknowledgments
  5. Introduction
    1. Who This Book Is For
    2. System Requirements
    3. Code Samples
    4. Support for This Book
      1. Find Additional Content Online
    5. Questions and Comments
  6. I. Getting Started
    1. 1. Computers, Xboxes, C#, XNA, and You
      1. Introduction
        1. Learning to Program
        2. Becoming a Great Programmer
      2. How the Book Works
      3. C# and XNA
      4. Getting Started
        1. Installing the Development Environment and the XNA Framework
        2. Setting Up a PC to Run XNA Games
        3. Setting Up an Xbox 360 to Run XNA Games
          1. XNA Creators Club
          2. Connecting an Xbox 360 to a Windows PC
      5. Writing Your First Program
        1. Creating Your First Project
        2. Running Your First Program
        3. Stopping a Program
        4. Storing Games on the Xbox 360
        5. Using a PC or an Xbox to Run XNA Games
      6. Conclusion
      7. Pop Quiz
    2. 2. Programs, Data, and Pretty Colors
      1. Introduction
      2. Making a Game Display
        1. Statements in the Draw Method
        2. Creating Your Own Color Values
          1. Storing Color Values
        3. Setting a Color Value
      3. Controlling Color
        1. Games and Classes
        2. Classes and Behaviors
        3. Classes as Offices
        4. Game World Data
        5. Storing Data in Computer Memory
        6. Drawing by Using Our Color Variables
        7. Updating Your Colors
        8. Memory Overflow and Data Values
        9. Making a Proper Mood Light
        10. Making Decisions in Your Program
          1. Creating Conditional Statements
          2. Adding an Else Part
          3. Testing Values
        11. The Completed Mood Light
          1. A Proper Funky Mood Light
        12. Finding Program Bugs
      4. Conclusion
      5. Pop Quiz
    3. 3. Getting Player Input
      1. Introduction
      2. Reading a Gamepad
        1. Gamepads and Classes
        2. Finding a Gamepad
        3. Testing the Gamepad Status
      3. Using the Keyboard
        1. Using Gamepad and Keyboard at the Same Time
      4. Adding Vibration
        1. Controlling the Vibration of a Gamepad
        2. Testing Intensity Values
      5. Program Bugs
      6. Conclusion
      7. Pop Quiz
  7. II. Using the XNA Framework
    1. 4. Displaying Images
      1. Introduction
      2. Resources and Content
        1. Getting Some Pictures
        2. Content Management Using XNA
        3. Working with Content Using XNA Game Studio 2.0
        4. XNA Game Studio 2.0 Solutions and Projects
        5. Adding Resources to a Project
          1. Adding Links to Resources
          2. The XNA Content Pipeline
      3. Using Resources in a Game
        1. Loading XNA Textures
        2. Positioning Your Game Sprite on the Screen
        3. Sprite Drawing with SpriteBatch
        4. Filling the Screen
          1. Intellisense
      4. Conclusion
      5. Pop Quiz
    2. 5. Writing Text
      1. Introduction
      2. Text and Computers
        1. Text as a Resource
        2. Creating the XNA Clock Project
        3. Adding a Font Resource
          1. The XML File Format
        4. Loading a Font
        5. Drawing with a Font
        6. Changing the Font Properties
      3. Getting the Date and Time
      4. Making a Prettier Clock with 3D Text
        1. Drawing Multiple Text Strings
        2. Repeating Statements with a for Loop
        3. Other Loop Constructions
        4. Fun with for Loops
      5. Creating Fake 3D
        1. Creating Shadows Using Transparent Colors
        2. Drawing Images with Transparency
      6. Conclusion
      7. Pop Quiz
    3. 6. Creating a Multiplayer Game
      1. Introduction
        1. Level and Edge Detectors
        2. Constructing the Complete Game
        3. Adding Test Code
      2. Conclusion
      3. Pop Quiz
    4. 7. Playing Sounds
      1. Adding Sound
        1. Creating the DrumPad Project
          1. Projects and Folders
        2. Capturing Sounds with Audacity
          1. Sounds and File Types
        3. Storing Sounds in Your Project
      2. Using the XACT Audio Creation Tool
        1. Starting XACT
        2. Using XACT
          1. Creating an XACT Project
          2. XACT Wave Banks
          3. XACT Sound Banks
          4. Auditioning the Sounds
          5. Building the Sound Project
          6. XACT and Sounds
        3. Using Sounds in an XNA Program
          1. Creating an Audio Engine
          2. Creating and Playing Sounds
        4. Playing Background Music
          1. Using Sound Cues to Control Playback
      3. Conclusion
      4. Pop Quiz
    5. 8. Creating a Timer
      1. Making Another Game
        1. Reaction Timer Bug
      2. Finding Winners Using Arrays
        1. Creating an Array
        2. Using Data in an Array
        3. Scanning an Array
        4. Using an Array as a Lookup Table
        5. Displaying the Winner
      3. Conclusion
      4. Pop Quiz
    6. 9. Reading Text Input
      1. Using the Keyboard in XNA
        1. Creating the Message Board Project
        2. Registering Key Presses
          1. Detecting When Keys Are Pressed
        3. The Keys Type
        4. Enumerated Types
      2. Working with Arrays, Objects, and References
        1. Values and References
        2. Arrays as Offices
        3. Say Hello to the Garbage Collector
        4. Using References and Values
        5. Why Do We Have References and Values?
        6. References and GetPressedKeys
      3. Displaying Keys
        1. Detecting Key Presses
          1. References and null
          2. Using break to Improve Performance
        2. Decoding Key Characters
      4. Conclusion
      5. Pop Quiz
  8. III. Games and Programming
    1. 10. Using C# Methods to Solve Problems
      1. Introduction
      2. Playing with Images
        1. Zooming In On an Image
      3. Creating a Zoom-Out
        1. Updating the Drawing Rectangle
        2. A Method to Calculate Percentages
          1. Putting a Method into Your Game Class
          2. Calling a Method
        3. Returning Nothing Using Void
          1. Creating a getPercentage Method
          2. Testing a Method
          3. Designing Tests for getPercentage
          4. Creating the getPercentage Method Body
        4. Debugging C# Programs
          1. Debugging with Breakpoints
        5. Hitting a Breakpoint
          1. Viewing Variables
        6. Using Floating Point Numbers in C#
        7. The Compiler and C# Types
        8. Compilers and Casting
        9. Expression Types
        10. Stopping the Zoom
        11. Zooming from the Center
      4. Conclusion
      5. Pop Quiz
    2. 11. A Game as a C# Program
      1. Introduction
      2. Creating Game Graphics
      3. Projects, Resources, and Classes
        1. XNA Game Studio 2.0 Solutions and Projects
        2. The Program.cs File
          1. Namespaces and Programs
          2. Static Classes and Methods
          3. Making Methods Static
          4. Main Method Parameters
          5. The C# Using Statement
          6. The Main Method in an XNA Game
        3. Renaming the Game1 Class
      4. Creating Game Objects
        1. Sprites in Games
        2. Managing the Size of Game Sprites
          1. Working with Floating Point Values and Integers
          2. Double Precision Floating Point Values
          3. Drawing and Aspect Ratios
          4. Sprite Sizing
        3. Moving Sprites
        4. Bouncing the Cheese
        5. Dealing with Display Overscan
      5. Conclusion
      6. Pop Quiz
    3. 12. Games, Objects, and State
      1. Introduction
      2. Adding Bread to Your Game
        1. Using a Structure to Hold Sprite Information
        2. Using the Gamepad Thumbsticks to Control Movement
        3. Improving Programs Using Methods
          1. Value and Reference Parameters
        4. Handling Collisions
        5. Making the Cheese Bounce off the Bat
        6. Strange Bounce Behavior
        7. Strange Edge Behavior
          1. Debugging a Running Program
      3. Adding Tomato Targets
        1. Tomato Collisions
          1. Controlling Sprite Visibility
          2. Setting the Initial Visibility state
          3. Using the Visibility field when drawing
      4. Conclusion
      5. Pop Quiz
    4. 13. Creating Gameplay
      1. Introduction
      2. Making a Finished Game
        1. Adding Scores to a Game
          1. Drawing Text in the Game
        2. Adding Survival
        3. Adding Progression
      3. Improving Code Design
        1. Refactoring by Creating Methods from Code
        2. Refactoring by Changing Identifiers
        3. Creating Code Regions
        4. Creating Useful Comments
      4. Adding a Background
      5. Adding a Title Screen
        1. Games and State
        2. Using the State Values
        3. Building a State Machine
      6. Conclusion
      7. Pop Quiz
    5. 14. Making Complete Games
      1. Introduction
      2. Hide The Gamepad
        1. Hide the Gamepad as a State Machine
        2. Creating a Timer
        3. Game Improvements
      3. Pelmanism
        1. Game Cards
        2. Adding Textures
        3. Setting Up The Game
          1. Selecting Picture Textures
          2. Shuffling by Swapping
          3. Random Numbers
          4. Pseudorandom Numbers
        4. Creating Pairs of Cards
        5. Shuffling the Card Pairs
        6. Playing the Game
          1. Moving the Cursor
        7. Selecting the First Card
        8. Detecting a Match
        9. Displaying the Selected Pair
      4. Pell Mell Pelmanism
        1. Making Pelmanism a Multiplayer game
      5. Game Creation
      6. Conclusion
      7. Very Silly Games
      8. verysillygames.com
  9. A. Pop Quiz Answers
    1. Chapter 1: Pop Quiz Answers
    2. Chapter 2: Pop Quiz Answers
    3. Chapter 3: Pop Quiz Answers
    4. Chapter 4: Pop Quiz Answers
    5. Chapter 5: Pop Quiz Answers
    6. Chapter 6: Pop Quiz Answers
    7. Chapter 7: Pop Quiz Answers
    8. Chapter 8: Pop Quiz Answers
    9. Chapter 9: Pop Quiz Answers
    10. Chapter 10: Pop Quiz Answers
    11. Chapter 11: Pop Quiz Answers
    12. Chapter 12: Pop Quiz Answers
    13. Chapter 13: Pop Quiz Answers
  10. B. Glossary
  11. C. Rob Miles
  12. Index
  13. About the Author
  14. Copyright