Preface

I’ve taught DirectX and XNA game development courses at Neumont University for the past several years, and I’ve been repeatedly frustrated by my inability to find the right book for these classes. There are numerous books on the subject, but none that I felt fit the goals of my classes (introductory college-level game development courses targeted to an audience familiar with C#) or that presented the material in a style and sequence I felt was appropriate.

Many books required too much previous game or graphics development knowledge. Others assumed too little knowledge of nongame-related development concepts. Still others relied too much on third-party libraries, or presented the material in a sequence that would be counterintuitive to a reader who is new to game development.

I found myself jumping around from Chapter 3 in one book to Chapter 18 in another, then back to the original book for Chapter 7 and Chapter 9, and so forth, while filling in gaps with slides, code samples, and documents I created on my own.

Eventually, I decided to take the content I had developed for my XNA game development course and write some material on the subject for use in the classroom. Initially, I was going to simply create some papers and essays to give to the students. I then realized that a large audience outside of the university would probably benefit from the material as well. I contacted O’Reilly about the book, and the rest is history.

Through my experience teaching XNA game development, I have been able to determine which points typically snag students and which points typically are easily grasped. I’ve also developed what I feel is a pretty straightforward way of presenting the material in a sequence that makes sense and is easy to follow. This book is designed to follow that sequence and to introduce concepts in a way that will help readers fully understand each individual topic.

Who This Book Is For

This book is meant to be a solid introduction to game development for somebody with basic knowledge of the .NET Framework and C# (or similar technologies). No previous XNA or other game or graphics development experience or knowledge is required.

How This Book Is Organized

This book introduces XNA game development concepts while walking the reader through the development of three different XNA games. Although most of the material generally applies to developing games for any of the available platforms, Chapters 16 and 17 focus on developing games for the Xbox 360 and Windows Phone 7, respectively.

The first portion of the book takes the reader through changes in XNA 4.0 and the development of a 2D game. Here are the chapters that compose this part:

Chapter 1, What’s New in XNA 4.0?

Takes the reader through the major changes in XNA 4.0 from previous versions.

Chapter 2, Getting Started

Walks you through a short introduction to XNA, the tools needed to develop games in XNA, and the installation of XNA Game Studio 4.0.

Chapter 3, Fun with Sprites

Introduces 2D sprites, transparency, sort order, movement, framerates, sprite sheets, and animation.

Chapter 4, User Input and Collision Detection

Covers user input from keyboards, mice, and Xbox 360 gamepads, as well as the implementation of collision detection.

Chapter 5, Applying Some Object-Oriented Design

Discusses and implements game components and applies an object-oriented class hierarchy to the design of your game.

Chapter 6, Sound Effects and Audio

Introduces the Microsoft Cross-Platform Audio Creation Tool (XACT) and the new simplified audio API as methods to add sound to your games on the PC, Xbox 360, and Windows Phone 7.

Chapter 7, Basic Artificial Intelligence

Explains the nature of the science of artificial intelligence and introduces basic artificial intelligence concepts. This chapter also walks through creating customized derived classes within your class hierarchy to implement different behaviors for your sprites.

Chapter 8, Putting It All Together

Puts the finishing touches on the 2D game, including 2D text, scoring, adding different types of sprites, background images, game states, and power-ups.

The next part of the book walks the reader through the development of a 3D game for the PC. At the end of this section, the game is tweaked and deployed to the Xbox 360. Here are the chapters in this part:

Chapter 9, 3D Game Development

Discusses coordinate systems, cameras, and drawing primitive objects, as well as moving, rotating, and scaling objects in 3D space. Culling and texturing surfaces are also discussed.

Chapter 10, 3D Models

Introduces 3D models and discusses drawing, rotating, and moving 3D models in 3D space.

Chapter 11, Creating a First-Person Camera

Walks the reader through the creation of a first-person vector-based camera in 3D, which implements forward and backward movement, strafing, and rotation in yaw, pitch, and roll.

Chapter 12, 3D Collision Detection and Shooting

Delves into the code behind shooting a moving enemy, creating a shot object, moving it in 3D space, and handling collision detection in 3D using bounding spheres. A 3D crosshair HUD (Heads Up Display) and audio effects are also added to the game.

Chapter 13, HLSL Basics

Introduces High Level Shader Language (HLSL) syntax and implementation, as well as the code required to use HLSL effects in XNA. A number of image manipulation effects are implemented using HLSL.

Chapter 14, Particle Systems

Walks the reader through the implementation of a custom vertex and a particle used to create an explosion particle effect.

Chapter 15, Wrapping Up Your 3D Game

Fine-tunes the 3D game, with sections covering splash screens, game states, scoring, and power-ups.

Chapter 16, Deploying to the Xbox 360

Walks the reader through connecting an Xbox 360 to a PC and deploying to the Xbox 360. User input and screen resolution differences between the PC and the Xbox 360 are discussed.

This next part of the book walks you through creating a new game for Windows Phone 7:

Chapter 17, Developing for Windows Phone 7

Walks the reader through the creation of a new game for Windows Phone 7 while discussing key differences between developing for Windows Phone 7 and other platforms.

The last part of the book walks you through creating a network game in XNA. This part assumes knowledge of all previous chapters and comprises only one chapter, which concentrates on networking functionality in XNA while stepping through the creation of a new XNA game:

Chapter 18, Multiplayer Games

Introduces multiplayer concepts through split-screen functionality as well as networking. Topics include network architectures, network states, communication via packets, and gamer services.

Finally, in the appendix, you’ll find the answers to the quizzes at the end of each chapter.

Support

My goal in writing this book is to help the reader gain a true understanding of and passion for game development in XNA. To that end, I’ll be supporting the book through my blog, which can be found at:

http://www.aaronreed.com/serenitynow/

On that website you’ll find the source code for the book, as well as other XNA-related content (and a fair bit of non-XNA-related content as well). Feel free to chime in on the forums with questions, comments, or even answers.

Conventions Used in This Book

The following typographic conventions are used in this book:

Italic

Used for emphasis, technical terms where they are defined, URLs, email addresses, filenames, file extensions, and pathnames

Constant width

Used for code samples, methods, functions, variables and their values, objects, and class names

Constant width bold

Used for emphasis in code samples

Tip

This icon signifies a tip, suggestion, or general note.

Warning

This icon indicates a warning or caution.

Using Code Examples

This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from this book does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Learning XNA 4.0, by Aaron Reed. Copyright 2011 Aaron Reed, 978-0-449-39462-2.”

If you feel your use of code examples falls outside fair use or the permission given here, feel free to contact us at .

We’d Like to Hear from You

We have tested and verified the information in this book to the best of our ability, but you might find that features have changed or that we may have made a mistake or two (shocking and hard to believe as that may be). Please let us know about any errors you find, as well as your suggestions for future editions, by writing to:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list examples and any plans for future editions. You can access this information at:

http://oreilly.com/catalog/0636920013709/

You can also send messages electronically. To be put on the mailing list or request a catalog, send an email to:

To comment on the book, send an email to:

For more information about our books, conferences, Resource Centers, and the O’Reilly Network, see our website at:

http://www.oreilly.com

Safari® Books Online

Note

When you see a Safari® Books Online icon on the cover of your favorite technology book, that means the book is available online through the O’Reilly Network Safari Bookshelf.

Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at http://my.safaribooksonline.com.

Acknowledgments

I explained what drove me to this madness in the first place at the beginning of this preface; that is, the book began from a need I had as an instructor to create a more comprehensive and straightforward way of teaching gaming and graphics. What has driven me to put together a second version of that book? In hindsight, I guess it was driven by some form of insanity. More than anybody, thanks go to my beautiful wife and for her never-ending support through all of this. Spending long nights in front of the keyboard and monitor isn’t the best way to keep a marriage going, but my wife puts up with a lot and has always been there for me. I love you so much! Thank you for always being there.

Thank you to my editor (Courtney Nash) and the technical reviewers of the book (Brett Beardall, Ryan Hair, Dan Waters, and others). Without your help, this book would be little more than the misguided ramblings of a boring computer science instructor. Uhh, well…it still might be just that, but either way, your help was invaluable.

Thanks to everybody at Neumont University for allowing me to pursue my two passions: technology and education. And thank you to the hundreds of students who’ve taken my classes over the years. Watching the lights go on inside students’ heads and the smiles on their faces when their graphics come alive on the screen truly is a special experience. It’s why I do what I do and, in the end, is the real reason this book exists.

Thanks to my parents for providing a way for me to fall in love with computers, programming, and technology in general. When I was a young teenager, I took apart our family computer to install a new SoundBlaster card. I wanted to pipe the output audio through our living room stereo and blast it throughout the house. I had never installed any hardware before that day and had no idea what I was doing. To my dread, my parents came home before I could finish hooking it all up and found me on the floor, scratching my head, surrounded by parts of our $2,500 computer. After explaining what I was doing, I was shocked that they didn’t yell at me and make me fix all the mess I had just created. What thrilled me even more was that when I finished putting it all together and hooked up the stereo, my parents were as excited as I was when I played with the talking parrot program and blasted the audio from a Star Wars game throughout the house. Experiences like that fed my interest in computers, helped me put aside any fear of failure, and instilled in me a passion for building things with technology. Parents of teenagers in America could learn a lot from the example of my parents: embrace your children’s interest (in technology or otherwise), funnel it into productive projects (not just playing games), encourage them to stretch themselves, and celebrate their successes.

Finally, thank you to Kyle Whittingham and Chris Hill for making University of Utah football such a success. It has nothing to do with this book, but it does make me smile. (Utah 31, Alabama 17.)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.122.127