Contents
Foreword
About the Authors
About the Technical Reviewer
Acknowledgments
Introduction
CHAPTER 1 Game Planning and Programming Basics
Planning the Game
Target Market
Game Genre
The Game Team
Game Planning
XNA Game Programming Concepts
General Game Structure
Game Initialization
Game Finalization
Game Loop
Summary
CHAPTER 2 2D Graphics, Audio, and Input Basics
2D Graphics
Common Gaming Terms
2D and Screen Coordinate Systems
Drawing a Sprite Using XNA
Moving the Sprite on the Screen
Coding for Collision Detection
Game Input
Using the Xbox 360 Gamepad
Using the Keyboard
Using the Mouse
Game Audio
Creating Audio Content with XACT
Using Audio in Games
Summary
CHAPTER 3 Creating Your First 2D Game
Design for the First Game: Rock Rain
Let's Get to It
Drawing the Background
Creating the Player's Game Component
Creating the Meteors
Creating the Game Logic
Adding Sounds
Adding a Scoreboard
Shake, Baby!
An Xbox 360 Version of Rock Rain
Summary
CHAPTER 4 Improving Your First 2D Game
Planning Rock Rain's New Version
Creating the Game Screens
Creating the Help Screen
Creating the Opening Screen
Creating the Action Scene
Navigating Between the Scenes
Summary
CHAPTER 5 Basics of Game Networking
Introducing Multiplayer Games
Network Topology
Turn-Based vs Real-Time Games
Some Technical Tips
Introducing XNA Networking
Starting the Gamer Services Component
Defining the NetworkHelper Class
Signing in a Gamer
Creating a Session
Finding and Joining a Session Synchronously
Finding and Joining a Session Asynchronously
Starting the Game
Handling Messages
Adding a Final Touch
Summary
CHAPTER 6 Rock Rain Live!
Planning Rock Rain Live
Adding the Support for Network Games
Changing the Opening Screen
Creating the Network Game Scene
Controlling the Input to the Scene
Creating the NetworkHelper Class
Creating the Game Sessions
Let's Talk
Synchronizing the Players
Adding Network Support to the Player Class
Adding Network Support to the PowerSource Class
Adding Network Support for the Meteors
Summary
CHAPTER 7 Rock Rain Zune
Planning Rock Rain Zune
Organizing the Game
Modifying the Classes
Help Scene Changes
Menu Changes
Power Source Changes
Meteor Changes
Player Changes
Core Game Changes
Deploying the Game on the Zune
Summary
CHAPTER 8 3D Game Programming Basics
3D Coordinate Systems and Projections
Vertices and Primitives
Vectors, Matrices, and 3D Transformations
Vectors
Matrices
Lights, Camera . . . Effects!
Drawing the 3D Axis in XNA
Coding the Vertices and the Vertex Buffer
Coding a Basic Effect and Rendering the 3D Scene
Coding the Main Program Calls
Models and Meshes
Summary
CHAPTER 9 Rendering Pipeline, Shaders, and Effects
Rendering Pipeline
Shaders
Vertex Shader
Rasterization
Pixel Shader
High-Level Shading Language
HLSL Data Types
Uniform and Varying Inputs
Semantics
Functions
Creating a Simple Shader
Techniques, Passes, and Effects
Effect Class
Effect Helper Classes
Materials
Shader Authoring Tools
Summary
CHAPTER 10 Lights, Camera, Transformations!
Cameras
A Base Camera Class
A Third-Person Camera
Lights
Base Light
Point Light/Omnidirectional Light
Camera and Light Managers
Camera Manager
Light Manager
Object Transformation
Summary
CHAPTER 11 Generating a Terrain
Height Maps
How Height Maps Work
Generating a Height Map
Creating the Terrain Class
Loading the Terrain Height Map
Generating the Terrain's Mesh
An Overview of Terrain Techniques
The Multitexturing Technique
The Normal Mapping Technique
Creating the Terrain Effect
Creating the Vertex Input and Output Structures for the Terrain Effect
Creating the Vertex Shader for the Terrain Effect
Pixel Processing for the Terrain Effect
Defining the Technique for the Terrain Effect
Setting the Effect Material
Drawing the Terrain
Extending the Terrain Effect with Normal Mapping
Vertex Processing for Normal Mapping
Pixel Processing for Normal Mapping
Querying the Terrain's Height
Ray and Terrain Collision
Summary
CHAPTER 12 Skeletal Animation
Types of Animations
Keyframed Animation
Skeletal Animation
Skeleton and Bone Representation
Extending the Content Pipeline for Model Animation
Creating the Animation Data Classes
Creating the Animated Model Processor
Reading and Writing Custom User Data
Using the AnimatedModel Class in XNA
Loading an Animated Model
Skeletal Animation Equations
Updating the AnimatedModel Class
Creating the AnimatedModel Effect
Converting the Mesh Effect
Drawing the Model
Summary
CHAPTER 13 Creating a Third-Person Shooter Game
Designing the Game
Game Definition
Game Play
Technical Design
Starting the Game Engine
Cameras, Lights, and Transformations
Terrain
Animated Model
Sky
Creating Helper Classes
Input Helper
Settings Manager
Random Helper
Creating the Game Logic
The Terrain Unit
Unit Types
Player Weapon
Player
Enemy
Finishing the Game Engine
Game Level
GameScreen Class
TPSGame Class
Summary
CHAPTER 14 Closing Words
Where You Are Now
Where Do You Go from Here?
Create Your Own Game
INDEX