Introduction

According to the point-of-sale information compiled by NPD Group (http://www.npd.com), a leading US marketing information provider, computer and video game sales totaled more than seven billion dollars in each of the past three years. The video game software industry accounts for more than six billion dollars of this total. If we include portable and console hardware, software, and accessory sales, in 2006, the video game industry generated revenue of close to twelve and a half billion dollars, exceeding the previous record of around two billion dollars. These figures alone might be reason enough to interest someone in learning XNA and becoming a game developer, trying to get a share of a market that's more profitable than the Hollywood moviemaking one.

But let's be fair and not hide the facts. Unfortunately, there are few openings in this area—about one game programming job per every thousand "real-life" programming jobs. Worse than that, on average, the game industry pays its programmers less than other industries do.

After digesting these facts, if you still think that working as a game developer might be cool and rewarding, then this book is for you! We also have some good news: now that Microsoft has opened its LIVE market to XNA games made by the community, there is a potential market of ten million people for your homemade games!

This book has the goal of introducing you to XNA, the cross-platform game programming framework from Microsoft, and also presenting you with basic concepts from the game programming industry, showing how these concepts apply to the XNA world. The samples in this book, which include some complete games, will give you the knowledge you need to create your own simple games.

That said, this book won't present you with hard-core math and physics or dig into advanced programming concepts, which are indeed needed if you really want to become a professional game developer. Instead, this book is a first step into this industry, presenting an overview of most of the things you need to know and giving you a road map for further studies in this area.

More than that, this book intends to be fun! One of the most interesting things you'll see in the game programming industry is the unmatched passion of the people who work in it. If there's one goal for this book, it's to light this passion in novices' hearts with simple explanations and, especially, with cool game examples, so this fire can keep burning in the years to come.

After all, this is a book written with a lot of passion!

What Is XNA?

XNA is a play on words. It stands for "XNA's Not an Acronym." Microsoft's world is so full of acronyms that it decided to create a name that looks like an acronym, but isn't, just for fun.

With Microsoft XNA, for the first time ever, a nonprofessional game developer can create single and multiplayer games that can run on a PC, the Xbox 360 console, and the Zune. The concept of bringing to the average Joe the power to create his own games for the Xbox 360 is a great technological innovation, which comes with many efforts from Microsoft to establish an active community for game creators, as well as to establish programs in the academic area to support institutions that wish to create courses using retail Xbox 360 consoles.

These efforts become obvious when you realize that Microsoft XNA Game Studio 3.0 can be downloaded at no charge from Microsoft's site (http://www.microsoft.com/XNA). Microsoft also offers free game content, including video tutorials, starter kits (ready-made games, which can be freely customized), samples, and other support content at the XNA Creators Club web site (http://creators.XNA.com).

The last step in making Microsoft LIVE known as the "YouTube for games" is the ability to upload the games you created and distribute (or even sell) them to anyone in the world with a LIVE connection. No wonder the nonprofessional game programmer community is so excited by XNA Game Studio and the frequent updates and new content on the XNA Creators Club site!

The greatest secret behind XNA's success is that it's easy—much easier than any console programming application programming interface (API) or Windows game programming API. That's because of the abstraction it provides for details that you need to worry about in other APIs. XNA uses the same integrated development environment (IDE)—XNA Game Studio Express—and the same framework for developing games for Windows, Xbox 360, and Zune platforms, which ensures a high degree of compatibility. However, there are differences in the lower layer: the Xbox 360 and the Zune run a compact version of the .NET Framework, so you must be careful—not all functions available in Windows will run on the Xbox 360 or Zune.

We'll address all this in detail in this book, but you can always find the latest information about XNA architecture at Microsoft's XNA site and at the XNA Creators Club site.

Who This Book Is For

This book is written for anyone who wants to start developing games for the Windows, Xbox 360, and/or Zune platforms. It can be used as a first step on a long road toward a game development career or as a guide to hobby game development. For example, perhaps you have a great idea for a simple game—the next Tetris—and have always wanted to have the basic knowledge, straight and simple, of how to create games. So, this book is for you if you want to have fun creating or modifying simple games and sharing them with friends.

How This Book Is Structured

This book is organized so you can start learning generic game programming concepts, such as common gaming terminology and math, see how these concepts are implemented in XNA, and then apply these concepts to real games. We believe that this organization improves your learning, so you'll be ready to create your own XNA games after finishing the book. Here's a quick chapter-by-chapter rundown:

Chapter 1, Game Planning and Programming Basics: This chapter presents important game planning concepts that will help you create great games, and also some general game programming concepts and how these concepts map to XNA. You'll also create your first XNA program.

Chapter 2, 2D Graphics, Audio, and Input Basics: This chapter introduces some fundamental concepts related to 2D game programming. You'll also see with some samples that demonstrate how the XNA Framework implements these concepts.

Chapter 3, Creating Your First 2D Game: This chapter is where the real fun begins! You'll find out how to put together the ideas presented in the first two chapters to create a complete game, named Rock Rain.

Chapter 4, Improving Your First 2D Game: Still in the 2D programming world, in this chapter, you'll explore other concepts such as creating menus, moving through game screens, managing players' scores, and more.

Chapter 5, Basics of Game Networking: In this chapter, you'll learn about one of the most exciting features of XNA 3.0: the ability to create network-enabled games. You'll see how to connect different machines, either directly or through LIVE.

Chapter 6, Rock Rain Live!: Getting back to your 2D game, in this chapter, you'll create a multiplayer version. This includes a new opening scene that allows players to create or join a match in other machines.

Chapter 7, Rock Rain Zune: Just to show how simple it is to make a game for the Zune, in this chapter, you'll create a Rock Rain version that runs on this device.

Chapter 8, 3D Game Programming Basics: This chapter introduces the fundamentals of 3D game programming. You'll learn how to create a 3D scene, load and manipulate 3D objects, move the camera, and everything else you need to know to start digging into virtual 3D worlds.

Chapter 9, Rendering Pipeline, Shaders, and Effects: Getting deeper into the 3D world, you'll learn more details about the XNA Content Pipeline and the use of effects and shaders in XNA, paving the way to create your first 3D game.

Chapter 10, Lights, Camera, Transformations!: In this chapter, you'll create the base objects used in any 3D game, which will help you manage lights and cameras, and apply transformations to your 3D objects.

Chapter 11, Generating a Terrain: Every 3D game that uses a landscape needs a terrain. This chapter presents the steps for creating, adjusting, and drawing the terrain, and also how to calculate object collisions with the terrain.

Chapter 12, Skeletal Animation: XNA 3.0 doesn't offer default support to read and play animations created by the modelers along with the 3D models. This chapter shows you how to create a custom model processor to read and play animation data.

Chapter 13, Creating a Third-Person Shooter Game: In this chapter, you put it all together, using the knowledge from the previous chapters to create a simple 3D third-person shooter game.

Chapter 14, Closing Words: As we said, this book is fun, and includes a lot of information about game programming, but it's only a first step. In this chapter, we present the advice we always give to our students when finishing a game programming course.

Prerequisites

Before you continue to the first chapter, be sure to download and install the latest version of XNA, which is easy to find in the Downloads section at http://www.microsoft.com/XNA. We also recommend that you download the DirectX Software Development Kit (SDK), which comes with some content and utilities you can use when learning XNA. Don't forget, also, to download and install the XNA starter kits and samples at http://creators.XNA.com. All these tools and samples are free to download and use.

If you don't have a copy of Microsoft Visual Studio, you should also download a free copy of Microsoft Visual C# Express, from http://www.microsoft.com/XNA.

Book Code and Errata

Although you can maximize your learning by typing the book code while you're reading, sometimes you simply can't wait to see the code running. If you're in a hurry, look for the book name at the Apress site, http://www.apress.com. All the book code is available for download from this book's details page.

Although Apress and the authors make their best efforts to ensure that there are no errors in the book code or text, sometimes an error appears. You can always find the most recent code and any text or code errata at the Apress site, http://www.apress.com. Again, just look for the book name.

Contacting the Authors

Alexandre Lobão is available from his personal web site, at http://www.AlexandreLobao.com, which includes all his works as an author, comics writer, and movie script writer.

Bruno Evangelista also maintains a personal web site, with his game programming projects, including downloadable content, at http://www.BrunoEvangelista.com.

José Leal is the head of a top Brazilian C# programming community, Sharp Games, available at http://www.sharpgames.net.

Riemer Grootjans can be contacted through the forum of his XNA community site at http://www.riemers.net.

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

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