This improved and updated edition of the bestseller will get you up and running quickly with building games for Xbox 360 and the Windows platform. Professional game developer and Microsoft MVP Benjamin Nitschke begins by explaining how to install the free XNA Game Studio 2.0 and then goes on to share essential advice for using it in a productive way. Before you know it, each successive chapter will have you developing small games that increase in difficulty. By using the chapters as building blocks, you'll evolve from 2D programming to 3D, and you'll ultimately create a full-blown graphics engine that can be used for more advanced game projects. Plus, you'll get an inside look at six fully functional games, including the popular Racing Game and the new Dungeon Quest.
What you will learn from this book Tips for adding music and sound with XACT Techniques for creating unique visual effects through Shaders Ways to access keyboard, mouse, and Xbox controllers with XInput How to write your own XNA graphics engine and create a game engine How to manage content in XNA Myriad ways of fine-tuning, debugging, and troubleshooting How to make sure games run on the Xbox 360 Ways to generate landscapes and tracks How to take advantage of XNA's new networking APIs Who this book is for This book is for anyone who wants to create games on the Xbox 360 and Windows platforms. Experience with C# or a similar .NET language is necessary, but previous game programming is not required. Wrox Professional guides are planned and written by working programmers to meet the real-world needs of programmers, developers, and IT professionals. Focused and relevant, they address the issues technology professionals face every day. They provide examples, practical solutions, and expert education in new technologies, all designed to help programmers do a better job.
Table of Contents
Acknowledgments. Introduction. Part I: XNA Framework Basics. Chapter 1: Introducing XNA. Introduction to the XNA Framework. XNA Game Studio Express. Application Model. Content Pipeline. Get the Free XNA Game Studio Express. Requirements. Installing. What About Visual Studio 2005 Professional? Configuring Your Xbox 360. Getting Started. Your First Project. F5 and Go. Changing the Code. Notes about XNA. Important Links. Is C# Good for Game Development? Getting Used to the Content Pipeline. Differences with MDX. Additional Tools and Tips. Changes in XNA 2.0. Troubleshooting. Summary. Chapter 2: Creating Your First Game: Pong. Game Ideas. Write Down Your Ideas! Agile Methodology. Solving Initial Difficulties. Creating Some Textures. Let's Write Pong. Sprites. Unit Testing in Games. Adding the Ball and Paddles. Handling Player Input. Collision Testing. Adding Sound. How This Looks on the Xbox 360. Challenge: Improve the Pong Game. Troubleshooting. Summary. Chapter 3: Helper Classes. Managing the Content Pipeline. Supported File Formats. Advantages and Disadvantages. Handling Content Directories. Importing and Accessing Content. Logging Error Messages. Unit Testing in XNA. NUnit and TestDriven.Net. Starting Unit Tests. Golden Rules. RandomHelper Class. Generate Random Vectors. StringHelper Class. Extracting Filenames. Writing Lists. Other Helpers. SpriteHelper Class. EnumHelper Class. ColorHelper Class. The Breakout Game. Unit Testing in Breakout. Breakout Levels. The Game Loop. Drawing Breakout. Collision Testing Challenge: Improve the Breakout Game. Summary. Chapter 4: Game Components. The Game Class. Game Component. More Helper Classe. TextureFont Class. Input Class. Sound Class. Tetris, Tetris, Tetris! Rendering the Background. Handling the Grid. Block Types. Gravity. Handling Input. Testing. Challenge: Create the NextBlock Game Component. Summary. Part II: Basic Graphics Engine. Chapter 5: Writing Your Own XNA Graphics Engine. What Should Your Engine Be Able to Do? The Engine Unit Test. 3D Models. Rendering of Textures. Line Rendering. 3D Programming. Model Unit Test. Testing Other Models. Plugging in More Game Components. Simple Camera Class. ScreenshotCapturer Class. Making Sure Games Run on the Xbox 360. Downloading the XNA Game Launcher. Xbox 360 Setup and Deploying Games. Console Debugging and Tools. Challenge: Write a Game Component. Summary. Chapter 6: Shader Management. Shader Overview. History. Shaders Everywhere in XNA. Example Games. Step-by-Step Shader Tutorial. FX Composer. FX File Layout. Parameters. Vertex Input Format. Vertex Shader. Pixel Shader. Importing the Shader into Your Engine. Compiling Shaders. Using Parameters. Vertex Formats. Rendering with Shaders. Testing the Shader. Challenge. Summary. Chapter 7: Realism Through Normal Mapping. Adding Detail to Objects. Problems. Asteroids! Wrong Game or What? So How Do Shaders Work? Vertex Shaders and Matrices. Pixel Shader and Optimizations. ShaderEffect Class. TangentVertex Format. Normal Mapping Unit Test. Adding Tangent Data with a Custom Processor. Final Asteroid Unit Test. More Shaders. Offset Mapping. Glass Shader. Reflection and Water. Challenge: Add Parallax Mapping. Summary. Chapter 8: Post-Screen Shaders and the Rocket Commander Game. Handling Post-Screen Shaders. Pre-Screen Sky Cube Mapping. Writing a Simple Post-Screen Shader. Improvements. Implementing Post-Screen Shaders. RenderToTexture Class. PostScreenDarkenBorder Class. Unit Test Result. More Post-Screen Shaders. Motion Blur. Color Correction. Menu Effects. Rocket Commander Game. Performance in XNA. Moving from MDX to XNA. Using Threads to Improve Performance. Result and Screenshots. Challenge: Write an Edge Detection Shader. Summary. Part III: Improving Your Game Engine. Chapter 9: Adding Sound with XACT. No DirectSound. Handling .wav Files. Using XACT. Creating Projects. Creating Your Wave Bank. Compressing Music Data. Sound Banks. Cue Variables. Other Effects. Changes in XNA 2.0. Sound Class. Rocket Motor Sound. Whoosh, What Was That? Menu Sounds. Challenge: Create Your XACT Project. Summary. Chapter 10: Player Input and the User Interface. Input Class. The Update Method in the Input Class. Mouse Rectangles. Entering Text in XNA. Game Screens. Help Screen. In-Game User Interface. Tips. Cameras. Space Camera. Challenge: Write a Free Camera Class. Summary. Chapter 11: Creating XNA Shooter. Putting It All Together. Sounds. User Interface. Textures. 3D Models. Animated Textures. Billboards. Landscape Rendering. Base Texture and Normal Map. Height Map. Adding Objects. XNA Shooter Game. Game Logic. 3D Effects. Unit Class. Projectile Class. Item Class. Final Screenshot. Challenge: Write a Game with Your Engine. Summary. Part IV: Writing a Racing Game. Chapter 12: Generating Landscapes and Tracks. Game Comparisons. Gran Tourismo. Need for Speed. Trackmania. XNA Racing Game. Landscape Rendering. Textures. Rendering. Optimizing Tips. Tracks. Unit Testing to the Rescue. Interpolating Splines. More Complex Tracks. Importing the Track Data. Generating Vertices from the Track Data. Final Result. Challenge: Create a New Unit Test Track. Summary. Chapter 13: Physics. Newton's Laws of Motion. Keep It Simple. Gravitation. Physics Engines. Ageia PhysX. Havok. ODE. Other. Implementing Physics. Handling Loopings. Spring Physics. Collision Detection. PhysicsAsteroidManager. Car Collision. Challenge: Figure Out the Road Collision. Summary. Chapter 14: Fine-Tuning and "Modding" the Racing Game. Game Concept. Game Idea. Additional Features. Game Screens. Splash Screen. Main Menu. Game Screen. Highscores. Final Unit Testing and Tweaking. Tweaking the Track. Shadow Mapping. Final Testing on Windows. Final Testing on the Xbox 360. Additional Ideas. More Cars. Online Highscore List. More Shaders and Effects. More Game Modes. Multiplayer Mode. Challenge: Write Your Own Mod! Example Game: Speedy Racer. Summary. Part V: Writing Multiplayer Games. Chapter 15: Multiplayer and Xbox Live. What's New in XNA 2.0. Overview About Networking in XNA 2.0. TCP Versus UDP. Firewalls and Punching Through NATs. Network Architecture. Sending UDP Data. Connecting Two Players. Network Messages. Server Game List. Writing a Chat Application. Game Screens. Handling Chat Messages. The Final Chat Application. Challenge: Write a Multiplayer Application. Summary. Chapter 16: Role-Playing Games. Types of Role-Playing Games. "Hack and Slash" Role-Playing Games. Massively Multiplayer Role-Playing Games. Designing Dungeon Quest. Ideas. Scenario. Story. Characters. Enemies. Weapons and Items. Abilities and Spells. Abilities. Spells. Leveling System. Challenge: Improve the Leveling System. Summary. Chapter 17: Dungeon Quest. Creating the Engine. Changes to the Graphic Engine. Using Collada Model Files. Handling Many Point Lights. Adding AI. Path-Finding. Alert-System via Cries. Multiplayer Support. Network Messages. Xbox LIVE Support. The Dungeon Quest Editor. Summary. Appendix A: Resources. Index.
Benjamin Nitschke is the founder, lead programmer, and game designer at exDream entertainment. He is 26 years old, and lives in Hannover, Germany. He became a DirectX MVP of Microsoft in 2006 for his outstanding work in the DirectX community, especially with the free game Rocket Commander. He started young - at the age of 9 he bought his first computer, a C64. He did not have many games, but he was very eager to type in commands on the C64, and from that to writing the first applications and games in Basic was not a big step. A few years later, he finally got a PC (386) and started some small game projects (Tetris clones, shoot-em-up games, and so on). exDream entertainment was founded 10 years ago, and it released a couple of smaller games before the first RTS game, Arena Wars, was created. Arena Wars was the first commercial .NET game ever and was released in 2004, where it received more than 20 awards worldwide, especially for the great multiplayer modes. Recently, Benjamin has developed a couple of free open source games such as Rocket Commander and the XNA Racing Game Starter Kit, along with many game modifications. These games feature many video tutorials and a good documentation and code style to help beginners create their first video games. The video tutorials have been viewed more than 100,000 times and the games were downloaded and played even more often than that.