Table of Contents

Preface ................................................................xiii

1. Getting Started..................................................... 1

System Requirements 1

Additional Resources 2

Installation 2

Creating Your First XNA Application 4

What You Just Did 5

Summary 6

Test Your Knowledge: Quiz 7

2. Fun with Sprites.................................................... 8

A Look Behind the Scenes 8

Game Development Versus Polling 11

Modifying Your Game 14

Adding a Sprite to Your Project 15

Loading and Drawing Your Sprite 18

Transparency and Other Options 21

Layer Depth 25

Let's Move 28

Animation 30

Adjusting the Framerate 35

Adjusting the Animation Speed 36

What You Just Did 38

Summary 38

Test Your Knowledge: Quiz 39

Test Your Knowledge: Exercise 39

3. User Input and Collision Detection ...................................40

More Sprites 40

Keyboard Input 43

Mouse Input 45

Gamepad Input 47

Keeping the Sprite in the Game Window 50

Collision Detection 50

What You Just Did 55

Summary 56

Test Your Knowledge: Quiz 56

Test Your Knowledge: Exercise 57

4. Applying Some Object-Oriented Design...............................58

Designing Your Classes 58

Creating a Sprite Class 59

Creating a User-Controlled Sprite Class 63

Creating an Automated Sprite 65

Game Components 67

Coding the SpriteManager 69

Cleaning Up 71

Making Them Move 74

What You Just Did 74

Summary 74

Test Your Knowledge: Quiz 75

Test Your Knowledge: Exercise 75

5. Sound Effects and Audio............................................76

Using XACT 77

Implementing XACT Audio Files in Code 83

Using the Simplified API for Sound and Audio 85

Adding More Sound to Your Game 86

What You Just Did 91

Summary 91

Test Your Knowledge: Quiz 91

Test Your Knowledge: Exercise 91

6. Basic Artificial Intelligence..........................................92

The Turing Test 93

Creating Sprites at Random Intervals 93

Randomly Spawning Sprites 95

Irrelevant Objects 99

Creating a Chasing Sprite 101

Creating an Evading Sprite 107

What You Just Did 112

Summary 113

Test Your Knowledge: Quiz 113

Test Your Knowledge: Exercise 113

7. Putting It All Together.............................................114

Drawing 2D Text 115

Randomly Generating Different Sprite Types 121

Adding Some Variety to Your Sprites 123

Adding a Background Image 128

Game Scoring 130

Game States 137

Enabling/Disabling GameComponents 141

Game-Over Logic and the Game-Over Screen 143

Fine-Tuning Gameplay 150

Creating Power-Ups 154

What You Just Did 159

Summary 159

Test Your Knowledge: Quiz 160

Test Your Knowledge: Exercise 160

8. Deploying to the Microsoft Zune....................................161

Setting Up Your Zune Device Connection 161

Creating a Zune Project 163

Input on the Zune 165

Audio on the Zune 167

Resolution and Gameplay Issues 169

Converting the Collision Game from Windows to Zune 170

Conditional Compilation Symbols 171

Converting the Collision Game Audio 173

Converting the Collision Game's Player Input Code 175

Converting the Collision Game's Screen Size 178

Zune Performance 179

What You Just Did 180

Summary 181

Test Your Knowledge: Quiz 181

9. 3D Game Development............................................182

Coordinate Systems 182

Cameras 184

Creating a 3D Camera 186

Drawing Primitives 189

Matrix Multiplication 194

Movement and Rotation 194

Backface Culling 197

More on Rotations 198

Even More Rotations 200

Primitive Types 202

Applying Textures 204

What You Just Did 209

Summary 209

Test Your Knowledge: Quiz 210

Test Your Knowledge: Exercise 211

10. 3D Models .......................................................212

Using 3D Models 212

Setting Up the Project 213

Adding a Model to Your Project 216

Drawing a Model Using a BasicModel Class 217

Adding a Model Manager 221

Rotating Your Model 224

What You Just Did 226

Summary 226

Test Your Knowledge: Quiz 226

Test Your Knowledge: Exercise 227

11. Creating a First-Person Camera.....................................228

Components of a Moving 3D Camera 228

Moving in a First-Person Camera 232

Rotations in a First-Person Camera 235

Coding the Camera for the 3D Game 240

What You Just Did 244

Summary 244

Test Your Knowledge: Quiz 245

Test Your Knowledge: Exercise 245

12. 3D Collision Detection and Shooting ................................246

Creating a Moving Enemy 246

Adding Some Game Logic 248

Firing Shots 257

3D Collision Detection and Bounding Spheres 261

Adding a Crosshair 265

Adding Sound 266

What You Just Did 273

Summary 273

Test Your Knowledge: Quiz 274

Test Your Knowledge: Exercise 274

13. HLSL Basics ......................................................275

HLSL Syntax 277

Dissecting a Sample HLSL Effect File 278

Applying an HLSL Effect in C# 287

Applying HLSL Using Textures 295

HLSL Effects: Creating a Negative 303

HLSL Effects: Blur 304

HLSL Effects: Grayscale 304

What You Just Did 306

Summary 307

Test Your Knowledge: Quiz 307

Test Your Knowledge: Exercise 307

14. Particle Systems..................................................308

Creating a Custom Vertex 308

Creating a Particle Engine 312

Adding a Particle Effect File 320

Adding Your Particle Engine to Your Game 322

Adding a Starfield 325

What You Just Did 330

Summary 331

Test Your Knowledge: Quiz 331

15. Wrapping Up Your 3D Game........................................332

Adding a Splash Screen Game Component 332

Keeping Score 342

Adding a Power-Up 347

What You Just Did 352

Test Your Knowledge: Exercise 353

16. Deploying to the Xbox 360 ......................................... 354

Adding an Xbox 360 Device 354

Converting a Project to Run on the Xbox 360 358

Supporting Gamepad Input 361

Deploying to the Xbox 360 367

Xbox 360 Display Settings 369

The Title Safe Region 370

What You Just Did 372

Summary 372

Test Your Knowledge: Quiz 373

17. Multiplayer Games................................................374

Split-Screen Functionality 374

Network Game Development 384

Network Configurations 385

Writing an XNA Network Game 387

Modifying the Sprite Class 388

Modifying the UserControlledSprite Class 388

Coding Your Game1 Class 391

Adding Update Code 394

Adding Draw Code 410

Adding Biohazard Bombs of Insanity! 415

What You Just Did 422

Summary 423

Test Your Knowledge: Quiz 424

Appendix: Answers to Quizzes and Exercises ...............................425

Index.................................................................477

0 0

Post a comment

  • Receive news updates via email from this site