Wiley Publishing, Inc.
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
© 2007 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in CanadaISBN: 9780470126776
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY:THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002.
Library of Congress Cataloging-in-Publication Data
Nitschke, Benjamin, 1980-
Professional XNA game programming: for Xbox 360 and Windows / Benjamin Nitschke.
Includes bibliographical references and index.
1. Computer games--Programming. 2. Microsoft XNA (Computer file) 3. Computer games. I. Title.
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Microsoft and XNA are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
This book is dedicated to all people that helped me in becoming a game programmer, especially all the
programmers out there creating engines and libraries, sharing knowledge, and writing reusable code to
help out fellow programmers.
About the Author
Benjamin Nitschke is the founder, lead programmer, and game designer at exDream entertainment. He is 26 years old, lives in Hannover, Germany, and also 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 they released a couple of smaller games until 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 like Rocket Commander and the XNA Racing Game Starter Kit and many game modifications for these games. These games feature many video tutorials and a good documentation and code style to help beginners create their first video games. The video tutorials were watched more than 100,000 times and the games were downloaded and played even more often than that.
First and foremost I would like to thank my parents for not supporting me at first in my childhood to work with computers. Only in this way did I become insanely interested and motivated in programming even without knowing anyone else that even had a computer.
I want to thank Chris Webb for giving me the opportunity to become an author. I also want to thank Kenyon Brown, Jim Perry, and everyone else at Wiley. It was an absolute pleasure to work with all of you.
I would also like to thank my colleagues and friends supporting me in my game projects. Thanks to Enrico Ciesiek for helping me out with the chapters and thanks to Christoph Rienaecker for giving me so many cool 3D models for my games. Thanks also fly out to Boje Holtz, Leif Griga, and Manuel Nitschke for testing and feedback.
Without the hard work of the XNA team, and also the .NET, DirectX, and Xbox 360 teams at Microsoft this book would not have been possible. They are not only responsible for creating XNA, DirectX, .NET, and many other frameworks that made this book and the games in it as useful as they are, but they are also incredibly cool guys, who are easy to talk to and very supportive. I especially want to thank Christina Storm, Tom Miller, Mitch Walker, Dave Mitchell, Dirk Primbs, and Uwe Baumann at Microsoft.
Finally, I also want to thank my family and friends for supporting me throughout the time I wrote this book. They may be used to the fact that I sometimes do not sleep for a couple of days just focusing on my projects, but it might not have been easy for them during that time. In a way, this is my gift to all of you.