Copyright
Game Coding Complete, Third Edition
Mike ―MrMike‖ McShaffry et al.
Publisher and General Manager, Course Technology PTR:
Stacy L. Hiquet
Associate Director of Marketing:
Sarah Panella
Content Project Manager:
Jessica McNavich
Marketing Manager:
Jordan Casey
Acquisitions Editor:
Heather Hurley
Project and Copy Editor:
Marta Justak
Technical Reviewer:
Sascha Friedmann, Vincent Magiya
PTR Editorial Services Coordinator:
Jen Blaney
Interior Layout Tech:
Bill Hartman
Cover Designer:
Kris Taylor
Indexer:
Larry Sweazy
Proofreader:
Heather Urschel
Course Technology,
a part of Cengage Learning
20 Channel Center Street
Boston, MA 02210
USA
For your lifelong learning solutions, visit courseptr.com.
Visit our corporate Web site at cengage.com.
Printed in the United States of America
1 2 3 4 5 6 7 11 10 09
© 2009 Course Technology, a part of Cengage Learning.
ALL RIGHTS RESERVED. No part of this work covered by the copyright herein may be
reproduced, transmitted, stored, or used in any form or by any means graphic, electronic,
or mechanical, including but not limited to photocopying, recording, scanning, digitizing,
taping, Web distribution, information networks, or information storage and retrieval
systems, except as permitted under Section 107 or 108 of the 1976 United States Copyright
Act, without the prior written permission of the publisher.
For product information and technology assistance, contact us at Cengage Learning
Customer & Sales Support, 1-800-354-9706
For permission to use material from this text or product, submit all requests online at
cengage.com/permissions.
Further permissions questions can be e-mailed to permissionrequest@cengage.com.
Microsoft, Microsoft Windows, Visual Studio, Internet Explorer, Xbox, Xbox360, and DirectX
are either registered trademarks or trademarks of Microsoft Corporation in the United States
and/or other countries.
3ds Max and Maya are either registered trademarks or trademarks of Autodesk, Inc. in the
United States and/or other countries.
Gamecube and Wii are trademarks of Nintendo Company, Ltd. in the United States and/or
other countries.
PlayStation, PlayStation 2, and PlayStation 3 are either registered trademarks or
trademarks of Microsoft Corporation in the United States and/or other countries.
Photoshop is a registered trademark of Adobe Systems Incorporated in the United States
and/or other countries.
Ultima and Ultima Online are either registered trademarks or trademarks of Electronic Arts,
Inc. in the United States and/or other countries.
All other trademarks are the property of their respective owners.
Library of Congress Control Number: 2008939941
ISBN-10: 1-58450-680-6
eISBN-10: 1-59863-696-2
Cengage Learning is a leading provider of customized learning solutions with office locations
around the globe, including Singapore, the United Kingdom, Australia, Mexico, Brazil, and
Japan. Locate your local office at: international.cengage.com/region.
Cengage Learning products are represented in Canada by Nelson Education, Ltd.
Dedication
This book and my life are dedicated to my wife and my best friend, Robin
Kudos
From Blue Phoenix:
I definitely hope that it‘s not the last publication you make, I‘m sure books can be a
challenge, but you‘ve done an amazing job. Kudos to you, the editors, publisher, and
everyone who helped produce this fine book.
From CdrJ:
Overall this book is pretty much all meat. I can‘t recommend it highly enough, and I‘ve
praised it to my entire team. It‘s probably the most useful game development text on my
shelf.
From Paul Jeffrey at Amazon.com
But here‘s a test you can take for yourself... go to www.mcshaffry.com/ GameCode and see
how Mike McShaffry is still helping folks who‘ve read his book (or anyone who posts on the
site for that matter). He‘s still giving free advice on his book‘s forum, when most other
authors won‘t even respond to an email.
From Codehead on Amazon.com
This is an excellent book. The author clearly is an expert on the subject, and he has spent
years developing mainstream commercial games (for example, Ultima series). This is a
refreshing change from so many books out there written by people with some theoretical
knowledge, but little practical application.
I will buy any book this guy writes in the future. Can‘t give a better recommendation than
that.
From spotland on Amazon.com
I have studied a lot of the ―standard‖ game coding books recently. This is the first game
book I have read that I was sorry when I got to the end because there wasn‘t any more. I
had to read it again. It is full of relevant content, peppered with real insights from someone
who has obviously been there and gotten the T-shirt. Because of its breadth of scope, it has
helped me fill in a lot of gaps left by some of the other texts. I have been programming in
C++ for over 13 years, and I still learned a few neat tricks. One of these was directly
relevant to a program I am writing—thanks for the tip!
Foreword
Let me start by admitting a couple of things. First, I‘ve never written a foreword for a book
before. I‘ve written books but never a foreword. Honestly, I usually skip right over these
things when I‘m reading a book, so odds are that no one is ever going to read what I‘m
writing here anyway. That makes it safe for me to move on to admission number two: I‘m
not a programmer. Never have been, and I fear, never will be, despite some valiant efforts
on my part (if I do say so myself). I‘ve done okay despite not knowing a blessed thing
about programming. I‘m not looking for sympathy or anything, but I am here to tell you
that a day doesn‘t go by when I don‘t think, ―Damn, if only I knew my z-buffers from my
BSP trees!‖ If you‘re already a programmer, you‘ve got a huge leg up on me when I tried to
get into the electronic game biz! (And if you‘re not a programmer, do as I say and not as I
do—learn to program ASAP. Mike has some advice about how to do that in the pages that
follow. Pay attention.)
Okay, so with those two confessions out of the way, I figure there‘s a fair chance any
credibility I might have had is pretty well shot. Luckily for you folks, the guy who wrote this
book has credibility to burn. Mike McShaffry (or ―Mr. Mike‖ as he‘s known to most everyone
in the game biz) is the real deal. Mike is a genuine survivor. He is a guy who can talk the
talk because, Lord knows, he‘s walked the walk enough times to earn some talking time.
Mike‘s experience of game development runs the gamut in a pretty remarkable way. He was
there when teams were a dozen folks, and he‘s been around in the era of 20, 30, and 50-
person teams. He‘s done the start-up thing, worked for the biggest publishers in the
business, worked on ―traditional‖ games and decidedly untraditional ones—everything from
Ultima to Blackjack, single player, multiplayer, online and off, and just about everything
else you can imagine. When it comes to PC games, he speaks with the authority of someone
who‘s worn just about every hat it‘s possible to wear—programmer, designer, project
leader, director of development, studio head....
And I‘ve had the privilege of watching him learn and grow with each new project and each
new role. I was there when Mike got his first game job. I was one of the folks at Origin who
interviewed him back in the Bone Ages, back in the 20th century, way back in 1990, when
he applied for a programming job at Origin. (Seems like forever, doesn‘t it, Mike? Whew!)
He started out as ―just‖ a programmer on Martian Dreams, a game I produced for Origin,
but by the end of the project, he was the engine that drove that game to the finish line. The
game wouldn‘t have happened without Mike. His drive, dedication, love of games, knack for
on-the-fly design, natural leadership skills, ability to combine right brain and left brain (to
say nothing of his willingness to work crazy hours), drove all of us to work that much harder
and ensured that the game ended up something special (at least to those of us who worked
on it together—it sure didn‘t sell many copies!).
I honestly don‘t even remember if I ever gave Mike the title ―Lead Programmer‖ officially on
Martian Dreams, but he sure deserved it. The guy was a machine, working longer hours
than most people I‘ve worked with (and that‘s saying something in the game business). He
also managed to do more and better work in those hours than any human being should be
allowed to. It just ain‘t fair to the rest of us mere mortals. When Mike was on, there was no
touching him. And he was almost always on—after Martian Dreams, Mike did it again and
again, on Ultima VII, VIII, IX and a bunch of others. Scary really.
In retrospect, all those hours and all the hard work that seemed so necessary, back in the
days when we were all younger and more foolish than we are now, was probably an
indication that Mike, like the rest of us, didn‘t have a clue about software development or
game design or much anything else. (Okay, we had a pretty good handle on the effects of
sugar and caffeine on the human body, but that‘s about it.) We had to work so long and so
hard just to have a chance in hell of ending up with something worthwhile.
Reading this book, I couldn‘t help but marvel at how much Mike‘s learned over the years
and wonder how much more Mike—and the rest of us—would have gotten done, how much
better our games might have been, if we‘d had the benefit of the kind of information in the
pages that follow. There just wasn‘t anyone around back then who knew enough about
games, programming practices, and software development. We were making it up as we
went along.
Today, there are plenty of books out there that can teach you the typing part of
programming. There are even some books that go a bit further and teach you what makes
- 1
- 2
- 3
前往页