Introduction

Welcome to Zune Game Development Using XNA 3.0, a book that was inspired by two of my lifelong passions: games and music. I was introduced to the wonder of PC games with groundbreaking titles such as Doom and Quake in the mid-1990s, and have been an avid gamer ever since. I was also brought up in a musical family. Over time, I have amassed a collection of guitars, drums, and other musical equipment that has ultimately failed in bringing my dreams of rock stardom to fruition.

I have also attempted to write my own games for different platforms with varying degrees of success. Since 1997, I have made efforts to wrap my head around technologies like DirectX and OpenGL to create a real game. I still have books on my shelf covering DirectX 3.1, game engine design, physics, and calculus. In my initial pursuits, I found it too difficult and time-consuming to learn such technologies with enough depth to be truly effective.

Rather than following my most heartfelt aspiration of making millions as a virtuoso guitar player, I opted for a computer science and engineering education, and became a software developer. I also tabled the idea of creating a real game due to the time investment, which I perceived as unrealistic.

My coding career eventually led me to work at Microsoft. Shortly after I started at Microsoft, XNA Game Studio 1.0 was released. I seized onto this glimmer of hope and made yet another attempt at creating my first real game.

Ten hours into working with XNA Game Studio, I had a rough version of Pong. Sure, Pong is not very impressive, but it has become the de facto "Hello World" application for new game developers. The best part was that I was able to see it running on my Xbox 360. At that moment, I was immersed in my own tangible accomplishment.

Microsoft has, in its own words, "democratized game development" to the level where you can build your own games. In the case of the Xbox 360, you can even distribute your games via Xbox Live Arcade Community Games. A new era of game development has dawned. Gone are the days of spending thousands of dollars on hardware and software just to be admitted into the inner circle of "serious" game developers. Microsoft has finally brought the joy of game development to the masses.

XNA Game Studio 3.0 adds support for creating games for the Zune portable media player. This concept is the focus of this book. Zune games bring several interesting concepts to the table. For example, you can listen to non-DRM music from your own library while playing a game, much as you can on the Xbox 360. Perhaps the most exciting element of Zune games is the ability to use the Zune's internal wireless hardware to create ad hoc game sessions with other Zunes.

To me, the true beauty of XNA lies in the fact that XNA games are based on the .NET Framework. This means that you can write satisfying, object-oriented code to implement cohesive objects and behaviors, without needing to worry about graphics. This makes your game a great candidate for automated tests, saving you a ton of time. Furthermore, it means that how you implement your game is entirely up to you. There is no right or wrong way to approach a particular problem; there is only the method that works for you and presents a satisfactory result.

The best way to learn XNA, regardless of your target platform, is to practice. Work through examples, try new things, and learn from your own mistakes. This book will help you develop a rich understanding of the XNA Framework and the Zune device, so that you can go on to produce games that are simply awesome.

What This Book Will Teach You

To understand Zune game development, you must first understand the XNA Framework. A good portion of this book is dedicated to the fundamental concepts involved in creating games with the framework.

You will first learn how to create a simple XNA game that you can run on your PC. This will demonstrate the basic concepts of XNA game development and set a course for success on the Zune. As you become more comfortable with XNA and its paradigms, you will learn how to translate those concepts to Zune development.

Not only will you learn about the technical side of game development specifically related to the .NET platform, but you will also get valuable information about tricks and techniques common to all games, including 2D space, trigonometry, sprites, animation, sound, and more.

You will learn all the requisites any eager reader looks for in a book such as this one. I will walk you through the creation of several different Zune games. You will see how to apply some advanced techniques. For example, you will master the music library and gain an understanding of network communications using packets. You will become familiar with the work flow of development and testing with the Zune device.

Developing for any mobile device requires cognizance of the device's limitations. You will need to think differently about input and control, as the Zune has very few physical buttons on it. Also, your personal coding style can greatly impact a device's memory and processor usage. You will learn good coding practices and habits to help you maximize your game's performance. You will develop an understanding of the currently available Zune devices, including their specifications and capabilities. To top things off, you will learn how to polish a Zune game, using graphics, effects, animation, transitions, and advanced input handling.

Zune Game Development Using XNA 3.0 is a comprehensive guide that will take you through the entire game development experience, teaching you important lessons along the way. Reading this book and following the examples will give you the experience and knowledge necessary to become successful in your endeavors with this burgeoning technology. My hope is to inspire you to take the ideas within and build on them to create something new and innovative.

Intended Audience

This book is intended for programmers with varying levels of experience in game development. You should have strong, practical experience with C# or a similar language (but note that C# is the only language currently supported by XNA Game Studio).

Whether you are an intermediate programmer aspiring to write your first game or a seasoned game development professional looking to branch out to a new platform, this book has something valuable to teach you. There is something here for individuals of every skill level, but I expect most readers to possess intermediate coding skills and a basic understanding of (or at least a passion for) games and game development.

The beginner will be introduced to many new programming concepts related to the .NET Framework, such as generic collections and highly structured object-oriented development practices. The beginner will benefit by starting with the first exercise of creating a game for your PC.

The intermediate student will feel sufficiently comfortable with most of the concepts and exercises in this book. Readers at an intermediate level will likely learn some useful new coding practices and will have little difficulty understanding the XNA Framework.

If you are an expert game developer experienced with other platforms such as C++, DirectX, Adobe Flash, or OpenGL, you will find the transition to XNA Game Studio to be a smooth and fulfilling one. You will be pleased to find that the required work to achieve most of your tasks is drastically reduced from what you might expect from your previous experiences with game development. You will be impressed by the consistency and speed with which managed code operates, even on the Zune. This book will serve as a guided reference to help you accomplish things you may have never thought possible in other software packages.

Regardless of your personal skill level or background, this book can help to take your programming and game development skills to the next level and open up new possibilities for single-player or social games.

How to Use This Book

Zune Game Development Using XNA 3.0 is much more than a reference manual. While you should be able to pick the book up at any time and find an example of what you are trying to accomplish, there is a clear path you can take through the book to master Zune game development in a well-rounded manner. This book has been structured in such a way that each concept builds upon the last, although you can jump in at almost any chapter using the downloadable example files.

In the information age, most of us use a search engine to find information on a particular technique. This can cause you to begin using an approach without fully understanding why you are using it; you only know that it works. Later down the road, you may find a bug or unintended behavior related to the usage of such a solution. To address this, I have made sure to highlight not only the how, but also the why.

As a programmer, you likely understand that there is no good substitute for hands-on experience. This book is full of such experiences that will help you make smart and informed decisions about the construction of a game. Rather than robotically enumerating the various methods and objects in the XNA Framework, this book frames the XNA development platform with real examples, real stories, real applications, and real games.

The exercises and knowledge checks provided throughout the chapters are intended to challenge your understanding of the concepts at hand. They are also intended to make you think about further applications in your own gaming goals.

Well-commented source code and documentation are available for every example. Having the code gives you the opportunity to explore and dig deeper. Some exercises suggest that you implement a particular game behavior in an existing project. This allows you to focus on a particular technique, without needing to write an entire game to demonstrate it.

Please feel free to play with and exploit the samples to meet your personal learning goals. By doing so, you may be able to hone your techniques, or even learn something brand new!

Chapter Overview

As I mentioned, you may feel inclined to dive directly into a specific area of interest. Here's what you need to know about how this book is organized and what you can expect to find in each chapter:

Chapter 1, Getting Started: This chapter shows you how to set up your computer for Zune game development. All the software you need is readily available for you to download and install, free of charge.

Chapter 2, Introduction to XNA Game Studio 3.0: In this chapter, you learn about how XNA games are organized from a programming perspective. This helps you gain the necessary context about the XNA platform to begin developing for the Zune.

Chapter 3, Game Content: This chapter covers the creation of assets for your game, including images and sound. It also explores the content pipeline, which is the system that loads and uses your content in the game. Near the end of the chapter, you build your own custom content pipeline extension to support a custom content type.

Chapter 4, Developing for the Zune: In this chapter, you learn about the development process using Zune devices, the Zune specifications, how to handle input and play sounds, and more. In this chapter, you build your first "real" Zune game, called OutBreak.

Chapter 5, XNA Fundamental Game Programming Concepts: This chapter explores some of the most common aspects of game programming, including 2D mathematics, collision detection, game state management and game component classes. At the end of this chapter, you build a more complicated, component-based game called Monkey Feeder.

Chapter 6, Advanced Techniques: This chapter covers some tips, tricks, and advanced techniques that you can apply to Zune games. These include querying device status such as the battery level, using touch gestures, landscape mode, using isolated storage, creating visualizers, and more.

Chapter 7, Final Exercise: Multiplayer Crazy Eights: This chapter brings together all the concepts from the previous chapters into one extended exercise. You will learn how to implement networking, game components, optimization, and advanced drawing techniques into one coherent game that you can play with other Zunes.

This book also has three appendices. Appendix A offers a list of online resources for more information about XNA game development. Appendix B is a quick reference for Zune game development techniques such as animation, input handling, and gesture support. Finally, Appendix C provides the answers to the "Check Your Knowledge" questions in Chapters 2 through 6.

Hardware and Software Considerations

Unlike some other game development platforms, the system requirements for XNA Game Studio 3.0 are easily met by most modern Windows-based systems. XNA Game Studio is actually an add-on to Visual Studio 2008, not a separate application. The system requirements for building games with XNA are mostly the same as the requirements for Visual Studio 2008. Running XNA games on the PC requires some specific hardware capabilities.

Both components of the development package can be obtained at no charge. XNA Game Studio 3.0 is a free product, as is Visual C# 2008 Express Edition (although any variant of Visual Studio 2008 with C# installed is supported).

Most systems running Windows XP (Service Pack 2 or 3) or Windows Vista should be able to develop, test, and deploy games to the Zune. If you are developing a parallel Windows game for faster testing, your video card must support Shader Model 1.1 (2.0 recommended) and DirectX 9.0c. If you plan to develop only for the Zune, you just need to meet the system requirements listed in the following sections. The faster your system is, the faster you'll be able to compile and debug. However, your computer's system configuration will not impact the speed at which your games run on the Zune device.

Visual Studio 2008 System Requirements

Supported architectures are x86 and x64 (WOW). You can use one of the following operating systems:

  • Microsoft Windows XP, Service Pack 2 or Service Pack 3
    • Minimum of 192MB of RAM (384MB preferred)
    • At least a 1 GHz processor (1.6 GHz preferred)
  • Microsoft Windows Vista or Windows Vista, Service Pack 1
    • Minimum of 768MB of RAM (1GB preferred)
    • At least a 1.6 GHz processor (2.2 GHz preferred)
  • Microsoft Windows Server 2003, Service Pack 2
    • Minimum of 768MB of RAM (1GB preferred)
    • At least a 1.6 GHz processor (2.2 GHz preferred)

XNA Game Studio 3.0 System Requirements

Supported architectures are x86 and x64 (WOW). You can use one of the following operating systems:

  • Microsoft Windows XP Home, Service Pack 2 or later
  • Microsoft Windows XP Professional, Service Pack 2 or later
  • Microsoft Windows XP Media Center Edition, Service Pack 2 or later
  • Microsoft Windows XP Tablet Edition, Service Pack 2 or later
  • Windows Vista Home Basic Edition
  • Windows Vista Home Premium Edition
  • Windows Vista Business Edition
  • Windows Vista Enterprise Edition
  • Windows Vista Ultimate Edition

Generally speaking, users running Windows XP Service Pack 2 or later or Windows Vista will have no problems installing or using XNA Game Studio, as long as their system meets the processor and RAM requirements.

Note that although XNA Game Studio may successfully install on Microsoft Windows Server 2003, it is not officially supported for this operating system, and the software may not work as expected.

Language Support

XNA Game Studio 3.0 itself is available only in English, but on Windows Vista, it is supported under any of the available language settings. On Windows XP, XNA Game Studio may fail to install under some language settings.

Administrator Permission Requirements

Administrative elevation is required to install, but not to run, XNA Game Studio.

Required Software

You'll need the following software:

  • Visual Studio 2008 (any edition)
  • Visual C# 2008 Express Edition

Video Card

To run XNA games on Windows, your video card must support Shader Model 1.1 (2.0 or greater recommended) and DirectX 9.0c.

Zune Requirements

XNA Game Studio 3.0 supports all currently available Zune devices, including first-generation Zunes. To enable gaming functionality on these devices, the firmware must be version 2.5 or later. Firmware updates can be initiated through the Zune PC software (see Chapter 4 for details).

Downloading the Source Code

All of the chapter exercises and examples, complete with all the sound and graphical assets required for the games, can be downloaded from the Apress web site (http://www.apress.com). You can access the source code from this book's details page or find the source code at the following URL (search for Zune): http://www.apress.com/book/sourcecode.

Moving Forward

As you work through this book, you will be armed with many professional-grade skills and techniques for not only mobile game development, but also game development in general. Should you feel inspired to explore more complicated examples or platforms such as the Xbox 360, you can reference the resources suggested throughout the book. Online and printed resources are available to help you achieve your wildest dreams with XNA Game Studio.

If you have questions or wish to start a dialogue, please feel free to contact me through my blog at http://www.danwaters.com. Another good place to get involved in the XNA community is through the official forums at http://creators.xna.com. If you create something that you think really stands out, send me a message through my blog to show it off, and you may even be featured in the XNA community spotlight!

On behalf of the XNA team at Microsoft and the publication team at Apress, I wish you a fun and fulfilling experience learning how to bring innovative new game ideas to life using XNA Game Studio 3.0 and the Zune. Let's get started!

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

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