Tải bản đầy đủ (.pdf) (792 trang)

Microsoft® XNA™ Game Studio 3.0 Unleashed pot

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (7.14 MB, 792 trang )

ptg6022785
Microsoft
®
XNA

Game Studio 3.0
UNLEASHED
800 East 96th Street, Indianapolis, Indiana 46240 USA
Chad Carter
From the Library of Neil Preston
ptg6022785
Microsoft® XNA™ Game Studio 3.0 Unleashed
Copyright © 2009 by Chad Carter
All rights reserved. No part of this book shall be reproduced, stored in a retrieval
system, or transmitted by any means, electronic, mechanical, photocopying, recording,
or otherwise, without written permission from the publisher. No patent liability is
assumed with respect to the use of the information contained herein. Although every
precaution has been taken in the preparation of this book, the publisher and author
assume no responsibility for errors or omissions. Nor is any liability assumed for
damages resulting from the use of the information contained herein.
ISBN-13: 978-0-672-33022-3
ISBN-10: 0-672-33022-9
Library of Congress Cataloging-in-Publication Data:
Carter, Chad.
Microsoft XNA game studio 3.0 unleashed / Chad Carter.
p. cm.
ISBN 978-0-672-33022-3
1. Microsoft XNA (Computer file) 2. Computer games—Programming. 3. Video
games. I. Title.
QA76.76.C672C425 2009
794.8’1536—dc22


2008054527
Printed in the United States of America
Second Printing July 2009
Trademarks
All terms mentioned in this book that are known to be trademarks or service marks
have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of
this information. Use of a term in this book should not be regarded as affecting the
validity of any trademark or service mark.
Warning and Disclaimer
Every effort has been made to make this book as complete and as accurate as possi-
ble, but no warranty or fitness is implied. The information provided is on an “as is”
basis. The author and the publisher shall have neither liability nor responsibility to any
person or entity with respect to any loss or damages arising from the information
contained in this book or from the use of the CD or programs accompanying it.
Bulk Sales
Sams Publishing offers excellent discounts on this book when ordered in quantity for
bulk purchases or special sales. For more information, please contact
U.S. Corporate and Government Sales
1-800-382-3419

For sales outside of the U.S., please contact
International Sales

Editor-in-Chief
Karen Gettman
Executive Editor
Neil Rowe
Development Editor
Mark Renfrow
Technical Editor

Chris Williams
Managing Editor
Kristy Hart
Project Editor
Anne Goebel
Copy Editor
Bart Reed
Indexer
Lisa Stumpf
Proofreader
Language Logistics
Publishing
Coordinator
Cindy Teeters
Multimedia Developer
Dan Scherf
Cover Designer
Gary Adair
Compositor
Jake McFarland
From the Library of Neil Preston
ptg6022785
Contents at a Glance
Introduction 1
Part I Get Up and Running with XNA Game Studio on Your PC and Xbox 360
1 Introducing the XNA Framework and XNA Game Studio
7
2 XNA Game Studio and the Xbox 360
19
3 Performance Considerations

33
Part II Understanding XNA Framework Basics
4 Creating 3D Objects
55
5 Handling Input to Move Our Camera
83
Part III Content Pipeline
6 Loading and Texturing 3D Objects
113
7 Sound and Music
123
8 Extending the Content Pipeline
151
Part IV 2D in XNA Game Studio
9 2D Basics
171
10 2D Effects
191
11 Creating a 2D Game
217
Part V XNA Game Studio and the Zune
12 Programming for the Zune
255
13 Running the Game on the Zune
273
Part VI High Level Shader Language
14 HLSL Basics
291
15 Advanced HLSL
311

Part VII Physics and Artificial Intelligence
16 Physics Basics
325
17 Finite State Machines and Game State Management
343
18 AI Algorithms
375
From the Library of Neil Preston
ptg6022785
Part VIII 3D Effects
19 Advanced Texturing Techniques
391
20 Special Effects
417
21 Particle System
435
Part IX Putting It into Practice
22 Creating a 3D Game
471
23 Improving the Game
501
24 Finishing Touches
525
Part X XNA Framework Networking
25 Networking Basics
549
26 Creating Multiplayer Demos
565
27 Creating a Networking Game Skeleton
583

28 Creating a Turn-based Multiplayer Game
631
29 Creating a Real-time Multiplayer Game
671
Part XI Xbox LIVE Community Games
30 Best Practices for Creating an Xbox LIVE Community Game
719
31 Selling the Game on Xbox LIVE Marketplace
727
Index
739
From the Library of Neil Preston
ptg6022785
Table of Contents
Introduction 1
Part I Get Up and Running with XNA Game Studio on Your PC and Xbox 360
1 Introducing the XNA Framework and XNA Game Studio 7
What Is the XNA Framework?
7
The Foundation of the XNA Framework
8
XNA Today
9
Installing Visual C# 2008 Express
10
Installing the DirectX Runtime
15
Installing XNA Game Studio
15
Creating the Platformer Projects

17
Compiling and Running Platformer
18
2 XNA Game Studio and the Xbox 360 19
Creating an Xbox 360 Project
19
Buying the XNA Creators Club Subscription
20
Connecting the Xbox 360 to the PC
21
Deploying on the Xbox 360
23
Debugging on the Xbox 360
25
Creating a Test Demo for the Xbox 360
25
Programming for Dual Platforms
28
The .NET Compact Framework on the Xbox 360
31
3 Performance Considerations 33
Measure, Measure, Measure
33
The 80–20 Rule
34
Creating a Benchmark
35
Monitoring Performance on the Xbox 360
37
Managing Memory

38
Understanding the Garbage Collector
39
On the .NET Framework (Windows)
39
On the .NET Compact Framework (Xbox 360 and Zune)
40
Optimization Suggestions
41
Creating a Micro-Benchmark Framework
41
Sealing Virtual Methods
51
Collections
51
From the Library of Neil Preston
ptg6022785
Part II Understanding XNA Framework Basics
4 Creating 3D Objects 55
Vertices
55
Vectors
55
Matrices
56
Transformations
56
Translation
56
Scaling

56
Rotation
56
Transformations Reloaded
57
Creating a Camera
57
Projection
57
View
58
World
59
Vertex Buffers
59
Effects
63
Textures
65
Index Buffers
66
XNA Game Components
69
Checking Performance
72
DrawUserIndexedPrimitives versus DrawIndexedPrimitives
74
Transformations Revolutions
76
5 Handling Input to Move Our Camera 83

Creating a Game Service
83
Starting a Library
86
Working with Input Devices
89
Keyboard
89
Game Pad
93
Mouse (Windows Only)
97
Creating a Stationary Camera
98
Creating a First-person Camera
102
Creating a Split Screen
104
Part III Content Pipeline
6 Loading and Texturing 3D Objects 113
Understanding the Content Pipeline
113
Loading 3D Models
114
Texturing 3D Models
119
Microsoft XNA Game Studio 3.0 Unleashed
vi
From the Library of Neil Preston
ptg6022785

7 Sound and Music 123
Direct Access to Sound Files
123
Microsoft Cross-Platform Audio Creation Tool (XACT)
124
Wave Banks
124
Sound Banks
125
Understanding Variations
126
Updating Our Input Handler
134
Plugging In Our Sound Manager
139
Creating a Sound Demo
146
8 Extending the Content Pipeline 151
Creating a Skybox
151
Creating the Skybox Content Object
152
Creating the Skybox Processor
152
Creating the Skybox Content Type Writer
160
Creating the Skybox Reader
162
Using the Skybox
163

Content Pipeline Processor Parameters
165
Debugging the Content Pipeline Extension
167
Part IV 2D in XNA Game Studio
9 2D Basics 171
Sprite Batches
171
Sprite Blend Modes
173
Sprite Sort Modes
173
Save State Modes
174
Practical Sprite Batches
175
Splash or Loading Screen Demo
176
Drawing Multiple Sprites from One Texture Demo
177
Sprite Batch Blend and Sort Mode Demo
179
Progress Bar Demo
183
Using Sprite Fonts
187
Importing TrueType Fonts
188
Creating Bitmap Fonts
188

Drawing 2D Text
189
10 2D Effects 191
Cel Animation
191
Rotating and Scaling
201
Blending Mode Example
203
Contents
vii
From the Library of Neil Preston
ptg6022785
Fade to Color 204
Making Fire, Old-School Style
206
Explosions
214
11 Creating a 2D Game 217
Setting Up the Game Skeleton
217
Creating Parallax Scrolling
220
Switching States
229
Drawing Our Hero
230
Drawing Our Enemies
235
Handling Collision Detection

240
Winning and Losing
243
Adding Transitions
243
Adding Explosions
246
Adding Sounds
251
Part V XNA Game Studio and the Zune
12 Programming for the Zune 255
Display Album Art Demo
255
Deploying to the Zune
258
Updating the XELibrary
258
Fire Demo Zune Edition
260
Creating a Visualization Demo
262
Creating the Visualization
268
13 Running the Game on the Zune 273
Porting the Game to Run on the Zune
273
Running the Game in Landscape Mode
280
Optimizing the Game to Run on the Zune
283

Zune Limitations
286
Part VI High Level Shader Language
14 HLSL Basics 291
Understanding the Shader Process
293
HLSL Syntax
294
Variable Types
294
Semantics
296
Structs
296
Intrinsic Functions
298
Microsoft XNA Game Studio 3.0 Unleashed
viii
From the Library of Neil Preston
ptg6022785
Loops and Conditions 304
Vertex Shaders
304
Pixel Shaders
305
Techniques
305
Passes
306
Passing Application Data to the GPU

306
HLSL Demo
307
15 Advanced HLSL 311
Vertex Displacement
311
Postprocessing
313
Setting Up Our Game Code
313
Setting Up Our Effect Code
316
More Postprocessing Examples
317
Negative Image
318
Switching RGB Values
318
Sharpening the Image
318
Blurring an Image
319
Embossing
319
Grayscale
320
Chalk
321
Wavy
321

Part VII Physics and Artificial Intelligence
16 Physics Basics 325
Kinematics
325
Velocity
326
Acceleration
326
Force
330
Collisions
331
Momentum
331
Impulse
332
Conservation of Momentum
332
Kinetic Energy
332
Coefficient of Restitution
333
Conservation of Kinetic Energy
333
Solving Our Final Velocities
333
Creating a Collision Response Demo
334
Contents
ix

From the Library of Neil Preston
ptg6022785
17 Finite State Machines and Game State Management 343
Finite State Machine
343
Object-Oriented Design
344
Managing Game States
345
Managing Game States Demo
348
18 AI Algorithms 375
Setting Up Our Demo
375
Chase Algorithm
380
A Better Chase Algorithm
381
Evading Algorithm
382
Random Movement
382
Creating a Finite State Machine
384
Part VIII 3D Effects
19 Advanced Texturing Techniques 391
3D Lighting
391
Creating a Custom Vertex Format
391

Creating the Demo
394
Ambient Lighting
397
Directional Lighting
399
Bump Mapping
403
Normal Mapping
403
Parallax Mapping
407
Relief Mapping
410
Texture Animation
414
20 Special Effects 417
Transitions
417
Cross-Fade (Dissolve)
422
Directional Wipes
423
Making Fire
428
21 Particle System 435
Particle System Defined
435
Point Sprite Defined
436

Creating the Particle Class
436
Creating the VertexPointSprite Struct
442
Microsoft XNA Game Studio 3.0 Unleashed
x
From the Library of Neil Preston
ptg6022785
Creating the Particle System Engine 443
Point Sprite Effect File
452
Particle System Demo
455
Creating Particle Effects
458
Rain
458
Bubbles
461
Laser Shield
462
Laser Scanner
464
Poisonous Gas
465
The Colorful Effect
467
Part IX Putting It into Practice
22 Creating a 3D Game 471
Creating the Tunnel Vision Game

471
Creating the Game States
471
Adding a Skybox to Our Game
472
Compiling the Game
472
Creating the Game Logic
473
Creating the Crosshair
494
Creating the Game-Specific Camera
495
23 Improving the Game 501
Creating the Radar
501
Creating the Tunnel
504
Creating the Level Timer
508
Creating the HUD
510
Adding Scoring
511
Keeping Track of High Scores
512
24 Finishing Touches 525
Updating the Title Screen
525
Updating the Start Menu

528
Creating the High Score Screen
532
Updating the Options Menu
536
Updating the Remaining States
539
Using the Particle System
541
Adding Sound
542
Suggested Improvements
544
Contents
xi
From the Library of Neil Preston
ptg6022785
Part X XNA Framework Networking
25 Networking Basics 549
Network Architecture
549
Client/Server
549
Peer to Peer
550
Hybrid
550
System Link Versus LIVE
552
XNA Requirements for Networked Games

552
Membership Requirements
553
Hardware Requirements
554
Latency Issues
554
Packet Loss
555
Bandwidth Constraints
556
Voice
557
Packet Headers
557
Compression
558
Do Not Send Unneeded Data
561
Prediction and Smoothing
562
Inviting Others to Join the Game
563
26 Creating Multiplayer Demos 565
Creating a Network Demo for Windows and the Xbox 360
565
Local Ad-Hoc Wi-Fi Gaming on the Zune
578
27 Creating a Networking Game Skeleton 583
Creating the Template

583
Understanding the New Menu Layout
590
Refactoring Our Menu States
591
Creating the Network-Specific Game States
605
28 Creating a Turn-based Multiplayer Game 631
Game Design
631
Starting with the Network Template
632
Adding in Game-Specific Functionality
633
Adding in Multiplayer Game Play
652
Handling Players Leaving and Joining the Game
665
Wrapping Up the Game
669
Microsoft XNA Game Studio 3.0 Unleashed
xii
From the Library of Neil Preston
ptg6022785
29 Creating a Real-time Multiplayer Game 671
Game Design
671
Using the Networking Template
672
Adding in Game-Specific Functionality

672
Making It Multiplayer
689
Prediction and Smoothing
709
Part XI Xbox LIVE Community Games
30 Best Practices for Creating an Xbox LIVE Community Game 719
Handling Any Display
719
Game Artwork
720
Consistent Controls
720
Handling Menus Appropriately
721
Trial Mode Experience
721
Handling Any Audio System
722
Using the Gamer Profile
723
Networking Games
723
Using Rich Presence
724
Handling the Storage Device Correctly
724
Marketing the Game
725
31 Selling the Game on Xbox LIVE Marketplace 727

Reviewing Other Creators’ Games
727
Submitting Our Games
732
Making Money by Making Games
736
Index 739
Contents
xiii
From the Library of Neil Preston
ptg6022785
About the Author
Chad Carter authored the previous edition of this book, Microsoft XNA Unleashed:
Graphics and Game Programming for Xbox 360 and Windows. He is the Chief Technology
Officer at Robertson Marketing Group. He has been creating DirectX applications since
1996 and has developed games using Managed DirectX. Chad wrote a 3D locomotive
simulator for Norfolk Southern that is used to teach children to obey railroad
crossing signals. Chad’s website devoted to the XNA Framework can be found online
at www.xnaessentials.com.
From the Library of Neil Preston
ptg6022785
Dedication
To the most beautiful woman in the world, my wife Christy.
To my precious daughter Caleigh and my second daughter,
whom I will meet very soon.
From the Library of Neil Preston
ptg6022785
Acknowledgments
Just like the first book, a host of people were responsible for making this book a reality.
My wife was extremely supportive this time around as well. Writing this book took much

longer than the original book. Even though I spent much more time on the book than I
originally anticipated, she was patient with the hours I put in. There is absolutely no way
this book could have been completed if it were not for her support. Christy, I love you
more than ever! With Caleigh being older, it was a little more difficult for her this time
around. Caleigh, thank you for being patient with your daddy for the past few months! I
love you very much, and I’m very proud of how much you have learned over the last year.
Next, I want to give praise to my Lord, God Almighty, who sustained me during these
past few months while I completed this book. I also need to thank my pastor, Dr. Roy
Carter, and the prayer partners for their prayers for me as I took on this task.
Next, I’d like to thank Neil Rowe, an executive editor at Sams Publishing. He agreed to
work with me on this project and was my main point of contact at Sams. I’d also like to
thank the rest of the Sams team with whom I had direct contact on this project—Mark
Renfrow, Cindy Teeters, Anne Goebel, and Bart Reed. I’d also like to thank the rest of the
Sams team with whom I did not have any communication but were behind the scenes
making this book a reality. I’m looking forward to seeing those names on the first page.
Shawn Hargreaves, an XNA Framework developer at Microsoft, was the technical editor of
the first edition of this book. His blog can be found at />His blog and his forum answers helped me tremendously in learning this technology. I’d
like to thank all the XNA Framework developers and Microsoft in general for making this
great technology. XNA Game Studio is truly awesome!
Chris Williams was the technical editor of this book. He was a huge help in making sure I
didn’t just gloss over a topic. He also made sure things flowed in a manner that would
help those just starting out. He was very quick to turn around completed chapters and
was a tremendous help in getting this book done. He also helped me test the networking
chapters over Xbox LIVE.
I’d also like to thank my parents, John and Sandra Carter, for providing many things for
me, including good education. Their support means the world to me. I’d also like to
thank my wife’s mom and dad, Wilson and Vicki Newsome, for helping our family with
many of the duties that I would normally handle but abandoned to write this book. They
also helped keep my family company while I was unavailable.
I’d also like to thank my Twitter Tribe. They have put up with my constant updates as to

which chapter I was working on, what I was stuck on, and how far behind I was. If you
are so inclined, you can follow me on Twitter at />Finally, I’d like to thank you for picking up this book. I hope that it serves its purpose and
brings insight into some of the mysteries of writing games. This book does no good if it is
not read, so thank you, and happy programming!
From the Library of Neil Preston
ptg6022785
We Want to Hear from You!
As the reader of this book, you are our most important critic and commentator. We value
your opinion and want to know what we’re doing right, what we could do better, what
areas you’d like to see us publish in, and any other words of wisdom you’re willing to pass
our way.
As an executive editor for Sams, I welcome your comments. You can fax, email, or write me
directly to let me know what you did or didn’t like about this book—as well as what we
can do to make our books stronger.
Please note that I cannot help you with technical problems related to the topic of this book, and
that due to the high volume of mail I receive, I might not be able to reply to every message.
When you write, please be sure to include this book’s title and author as well as your
name and phone or email address. I will carefully review your comments and share them
with the author and editors who worked on the book.
Email:
Fax: 317-428-3310
Mail: Neil Rowe, Executive Editor
Sams Publishing
800 East 96th Street
Indianapolis, IN 46240 USA
Reader Services
Visit our website and register this book at www.informit.com/title/9780672330223 for
convenient access to any updates, downloads, or errata that might be available for this
book.
From the Library of Neil Preston

ptg6022785
This page intentionally left blank
From the Library of Neil Preston
ptg6022785
Introduction
Many developers became interested in programming because they saw a video game and
thought, “How did they do that?” This book helps demystify what is required to make video
games. Being able to write games on a next-generation console such as the Xbox 360 has never
been an option for the masses before. Now with the XNA Framework, games can be written for
the console.
By the end of this book, you will have created four complete games and many demos along the
way. This book takes a serious look at performance-related issues when writing games using XNA
for Windows and the Xbox 360. Two chapters are devoted to the High Level Shader Language
(HLSL), which is a necessity for writing great games. The book covers physics and artificial intelli-
gence (AI). It also covers special effects, including explosions, transitions, and how to create a 3D
particle system. It demonstrates how to create a sound project using the Microsoft Cross-Platform
Audio Creation Tool (XACT) and how to directly access sound files in a game. Two chapters are
devoted to programming games for the Zune. Saving and loading a high score list and creating a
full menu system are also taught in this book. Five chapters are devoted to creating multiplayer
games. Writing network games can be challenging, and this book covers networking in detail.
The final two chapters are on best practices and provide tips on how to sell games on the Xbox
LIVE Marketplace. In general, this book contains a great foundation for many topics that need to
be learned to create and sell a full-featured single-player or multiplayer game.
Who Should Read This Book?
This book was written for developers. You should have a good understanding of programming in
general. The book uses C#, but if you know any modern language, such as C++, Java, or VB.NET,
you will have no problem understanding the code in this book. The book assumes some under-
standing of the Microsoft .NET Framework, which is what the XNA Framework runs on. Without
prior experience writing code using the .NET Framework, you might have to do a little research
now and then, but should not have trouble getting through this book.

This book was written with a few different audiences in mind. Business application developers
who want to use their programming skill set to write computer games are one audience. Graphics
and game developers who have been around the OpenGL and DirectX block should also find
useful information in this book—especially in seeing how things are done “the XNA way.” The
book also targets readers who have some programming experience but have not done anything
formal. The book teaches by example. It is written in such a way that if you are not in front of
your computer, you can still get valuable information from the book because the code is
presented as it is being discussed.
From the Library of Neil Preston
ptg6022785
2
Introduction
Hardware and Software Requirements
The code in this book is compiled with XNA Game Studio 3.0. In order to complete the
games and demos in this book, the requirements that follow must be met.
Supported Operating Systems
The following operating systems are supported:
. Windows XP Home Edition
. Windows XP Professional Edition
. Windows XP Media Center Edition
. Windows XP Tablet Edition
. Windows Vista Home Basic Edition
. Windows Vista Home Premium Edition
. Windows Vista Business Edition
. Windows Vista Enterprise Edition
. Windows Vista Ultimate Edition
Windows XP requires Service Pack 2 or later.
Hardware Requirements
When you run XNA Framework games on Windows, a graphics card that supports Shader
Model 1.1 is required. This book has samples that use Shader Model 2.0 and a couple that

use Shader Model 3.0. To get the most from this book, you need a graphics card that
supports Shader Model 3.0. The graphics card should have the most up-to-date drivers.
Updated drivers can be found on the graphics card’s hardware vendor website.
When you run XNA Framework games on the Xbox 360 console, a hard drive must be
connected to the console.
Software Requirements
All the software required to utilize the XNA Framework on Windows is free:
. Microsoft Visual C# 2005 Express Edition
. Microsoft XNA Game Studio Express
. DirectX 9.0c
Instructions on installing the software can be found in Chapter 1, “Introducing the XNA
Framework and XNA Game Studio.”
From the Library of Neil Preston
ptg6022785
3
How This Book Is Organized
Code Examples
The source code for the examples in this book can be found on the accompanying CD.
Any updates to the code can be downloaded via www.samspublishing.com or
www.xnaessentials.com.
How This Book Is Organized
This book is organized into 11 main parts, representing the information you need to
understand to use XNA Game Studio effectively. Writing a book is an interesting chal-
lenge. There are basically two routes an author can go. One route is to create small bite-
sized pieces that can be used as a reference. The other route is to take the reader on a
journey from start to finish, covering important topics along the way but doing it in such
a manner that the reader is gradually learning concepts. Then, once the entire book has
been enjoyed, the reader can go back and reread certain sections for mastery.
I have tried to take the second approach in writing this book. The book is best read in
order. The Internet has a wealth of information. Learning about a particular topic is not

difficult. You can easily find information from many different sources on a particular
topic. The problem is there is usually no place to see how a lot of different topics work
together. With a book that is designed to be read from front to back, the main drawback is
a larger time commitment. However, there is usually deeper understanding by the time
the task is complete versus the same amount of time spent looking at particular topics on
the subject from online tutorials and blog posts. Both are very important, but because a
wealth of reference information is available online already, there was no need to make this
a reference book.
There was some criticism concerning the order of the first book. This book is not orga-
nized in a manner similar to many other books. However, a lot of thought was put into
the order of this book. I do believe this book’s order is important, and I did not change it
from the first edition. I start with a very basic chapter explaining the history of XNA and
very detailed instructions on how to install XNA Game Studio. Most people will not need
this, but it is there for those who do. The next chapter jumps right in to talking about the
Xbox 360. Even though there are people who do not have an Xbox 360, it is important to
put this chapter up front so you can be aware of certain things when creating games using
XNA. It is always important to know what you are up against before you start. It is for this
same reason that the very next chapter is on performance. Most books simply give a nod
to performance in a later chapter or maybe an appendix, if at all. I personally believe that
thinking about performance early on is crucial to making a good game. This does not
mean we need to do micro-optimizations early in the process; instead, it is all about
measurement. This is why performance is discussed so early in the book.
From the Library of Neil Preston
ptg6022785
4
Introduction
The first real game code that is presented in this book is written for 3D. Many people are
shocked that 2D is not discussed until Chapter 9, “2D Basics.” The reason for putting 3D
before 2D in this book is because picking up 3D is not any harder than learning 2D. The
early chapters are there to introduce you to the XNA Framework as well as the concepts

behind a camera. It is my hope to tear down the mental block many people have that 3D
is much harder than 2D. Granted, there are some complex topics surrounding 3D, and
those are covered later in the book. However, by getting started by drawing models and
responding to input, you’ll see there is not a huge difference in the knowledge needed to
write 3D games versus 2D games.
After discussing 3D and the Content Pipeline, the book discusses 2D and then moves into
two chapters devoted to programming for the Zune. The next part of the book discusses the
High Level Shader Language. Physics and artificial intelligence are discussed next. The code
for those chapters uses the basic 3D information you will learn in earlier parts the book.
This is followed up by talking about more advanced 3D topics. A single-player 3D game is
then built, thus allowing us to put into practice all you will learn in this book.
The next part of the book provides an intensive look at developing multiplayer games.
Then the final part of the book discusses some best practices, most of which are done
while creating the demos and games throughout the book. The last chapter explains the
review process and getting your game into a condition to be sold on the Xbox LIVE
Marketplace.
From the Library of Neil Preston
ptg6022785
PART I
Get Up and Running with
XNA Game Studio on
Your PC and Xbox 360
IN THIS PART
CHAPTER 1 Introducing the XNA Framework and XNA
Game Studio
CHAPTER 2 XNA Game Studio and the Xbox 360
CHAPTER 3 Performance Considerations
From the Library of Neil Preston
ptg6022785
This page intentionally left blank

From the Library of Neil Preston
ptg6022785
CHAPTER 1
Introducing the XNA
Framework and XNA
Game Studio
IN THIS CHAPTER
. What Is the XNA Framework?
. Installing Visual C# 2008
Express
. Installing the DirectX Runtime
. Installing XNA Game Studio
. Creating the Platformer
Projects
. Compiling and Running
Platformer
Most developers I know decided to enter the computer
field and specifically programming because of computer
games. Game development can be one of the most chal-
lenging disciplines of software engineering—it can also be
the most rewarding!
Never before has it been possible for the masses to create
games for a game console, much less a next-generation
game console. As a relatively new technology, XNA is going
to experience tremendous growth. The sooner we get to
know this technology, the better we will be able to under-
stand the changes that will come in the future.
Microsoft is leading the way in how content will be created
for game consoles. Soon other game console manufacturers
will be jumping at a way to allow the public to create

content for their machines. The great news for the Xbox
360 is that Microsoft has spent a lot time over the years
creating productive and stable development environments
for developers. We will be installing one of Microsoft’s latest
integrated development environments (IDEs) in this
chapter. Before we get to that, though, let’s take a look at
the technology we discuss in this book—XNA.
What Is the XNA Framework?
You have probably heard the statement, “To know where
you are going, you need to know where you have been.” I
am uncertain if that is entirely true, but I do believe it
applies here. Before we dig into exactly what XNA is and
what it can do for us, let’s take a moment to look at DirectX
because that is what the XNA Framework is built on.
From the Library of Neil Preston

×