100% found this document useful (1 vote)
11 views

Immediate download Beginning NET Game Programming in VB NET 1st Edition David Weller ebooks 2024

The document provides links to various eBooks available for download, including titles on .NET game programming, VB.NET, ASP.NET, and more. It includes details about the authors, technical reviewers, and the structure of the book 'Beginning .NET Game Programming in VB.NET.' Additionally, it outlines the contents of the book, including chapters on GDI+, artificial intelligence, and game development techniques.

Uploaded by

moleakuver0j
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
11 views

Immediate download Beginning NET Game Programming in VB NET 1st Edition David Weller ebooks 2024

The document provides links to various eBooks available for download, including titles on .NET game programming, VB.NET, ASP.NET, and more. It includes details about the authors, technical reviewers, and the structure of the book 'Beginning .NET Game Programming in VB.NET.' Additionally, it outlines the contents of the book, including chapters on GDI+, artificial intelligence, and game development techniques.

Uploaded by

moleakuver0j
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Download the Full Version of the Ebook with Added Features ebookname.

com

Beginning NET Game Programming in VB NET 1st


Edition David Weller

https://ebookname.com/product/beginning-net-game-
programming-in-vb-net-1st-edition-david-weller/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

VB to VB net Craig Utley

https://ebookname.com/product/vb-to-vb-net-craig-utley/

ebookname.com

Fast Track VB Net 1st Edition Rocky Lhotka

https://ebookname.com/product/fast-track-vb-net-1st-edition-rocky-
lhotka/

ebookname.com

Professional ASP NET 4 in C and VB 1st Edition Bill Evjen

https://ebookname.com/product/professional-asp-net-4-in-c-and-vb-1st-
edition-bill-evjen/

ebookname.com

Elementary Signal Detection Theory 1st Edition Thomas D.


Wickens

https://ebookname.com/product/elementary-signal-detection-theory-1st-
edition-thomas-d-wickens/

ebookname.com
Windows XP Hacks Second Edition Preston Gralla

https://ebookname.com/product/windows-xp-hacks-second-edition-preston-
gralla/

ebookname.com

Amyloid prions and other protein aggregates Part B 1st


Edition Indu Kheterpal

https://ebookname.com/product/amyloid-prions-and-other-protein-
aggregates-part-b-1st-edition-indu-kheterpal/

ebookname.com

Track field 1. print. Edition Gabrielle Vanderhoof

https://ebookname.com/product/track-field-1-print-edition-gabrielle-
vanderhoof/

ebookname.com

Gluten Free for a Healthy Life Nutritional Advice and


Recipes for Those Suffering from Celiac Disease and Other
Gluten Related Disorders 1st Edition Kimberly A. Tessmer
https://ebookname.com/product/gluten-free-for-a-healthy-life-
nutritional-advice-and-recipes-for-those-suffering-from-celiac-
disease-and-other-gluten-related-disorders-1st-edition-kimberly-a-
tessmer/
ebookname.com

Short Grammar of Bulgarian for English Speaking Learners 2


Revised Edition Evgenia Antova

https://ebookname.com/product/short-grammar-of-bulgarian-for-english-
speaking-learners-2-revised-edition-evgenia-antova/

ebookname.com
The 8 Biggest Mistakes People Make With Their Finances
Before and After Retirement 1st Edition Terence L. Reed

https://ebookname.com/product/the-8-biggest-mistakes-people-make-with-
their-finances-before-and-after-retirement-1st-edition-terence-l-reed/

ebookname.com
4010fm.qxd 8/20/04 2:33 PM Page i

Beginning .NET
Game Programming
in VB.NET
DAVID WELLER, ALEXANDRE SANTOS LOBÃO,
AND ELLEN HATTON
4010fm.qxd 8/20/04 2:33 PM Page ii

Beginning .NET Game Programming in VB.NET


Copyright © 2004 by David Weller, Alexandre Santos Lobão, and Ellen Hatton
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any
means, electronic or mechanical, including photocopying, recording, or by any information storage
or retrieval system, without the prior written permission of the copyright owner and the publisher.

ISBN (pbk): 1-59059-401-1

Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1

Trademarked names may appear in this book. Rather than use a trademark symbol with every
occurrence of a trademarked name, we use the names only in an editorial fashion and to the
benefit of the trademark owner, with no intention of infringement of the trademark.

Technical Reviewer: Andrew Jenks

Editorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Tony Davis,
Jason Gilmore, Chris Mills, Dominic Shakeshaft, Jim Sumser

Assistant Publisher: Grace Wong

Project Manager: Sofia Marchant

Copy Editor: Ami Knox

Production Manager: Kari Brooks

Proofreader: Linda Seifert

Compositor: Dina Quan

Indexer: Rebecca Plunkett

Cover Designer: Kurt Krames

Manufacturing Manager: Tom Debolski

Distributed to the book trade in the United States by Springer-Verlag New York, Inc., 233 Spring
Street, 6th Floor, New York, New York 10013 and outside the United States by Springer-Verlag
GmbH & Co. KG, Tiergartenstr. 17, 69112 Heidelberg, Germany.

In the United States: phone 1-800-SPRINGER, email orders@springer-ny.com, or visit


http://www.springer-ny.com. Outside the United States: fax +49 6221 345229, email
orders@springer.de, or visit http://www.springer.de.

For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219,
Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, email info@apress.com, or visit
http://www.apress.com.

The information in this book is distributed on an “as is” basis, without warranty. Although every
precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall
have any liability to any person or entity with respect to any loss or damage caused or alleged to
be caused directly or indirectly by the information contained in this work.

The source code for this book is available to readers at http://www.apress.com in the
Downloads section.
4010fm.qxd 8/20/04 2:33 PM Page v

Contents at a Glance
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xi
About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiii
About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xv
Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvi
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xix
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxi

Chapter 1 .Nettrix: GDI+ and Collision Detection . . . . . . .1


Chapter 2 .Netterpillars: Artificial Intelligence
and Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
Chapter 3 Managed DirectX First Steps: Direct3D
Basics and DirectX vs. GDI+ . . . . . . . . . . . . . . . . .141
Chapter 4 Space Donuts: Sprites Revisited . . . . . . . . . . . .207
Chapter 5 Spacewar! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245
Chapter 6 Spacewar3D: Meshes and Buffers and
Textures, Oh My! . . . . . . . . . . . . . . . . . . . . . . . . . . . . .271
Chapter 7 Adding Visual Effects to Spacewar3D . . . . . . . .327
Epilogue Taking Your Next Steps . . . . . . . . . . . . . . . . . . . . . .343
Bonus Chapter Porting .Nettrix to Pocket PC . . . . . . . . . . . . . .351
Appendix A Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . .371
Appendix B Motivations in Games . . . . . . . . . . . . . . . . . . . . . . . . .375
Appendix C How Do I Make Games? . . . . . . . . . . . . . . . . . . . . . . . . .381
Appendix D Guidelines for Developing
Successful Games . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .391
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .399

v
4010fm.qxd 8/20/04 2:33 PM Page vii

Contents
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xi
About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiii
About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xv
Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvi
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xix
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxi

Chapter 1 .Nettrix: GDI+ and Collision Detection . . . . 1


Basic GDI+ Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2
Performing Graphic Operations with a Graphics Object . . . . . . . . . .4
Creating Gradients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7
Collision Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8
Optimizing the Number of Calculations . . . . . . . . . . . . . . . . . . . . . . . . . .18
Extending the Algorithms to Add a Third Dimension . . . . . . . . . . . .22
The Game Proposal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
The Game Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
The Coding Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
Final Version: Coding the GameField Class and
the Game Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51
Adding the Final Touches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64
Book Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64

Chapter 2 .Netterpillars: Artificial


Intelligence and Sprites . . . . . . . . . . . . . . . . . . . . . 65
Object-Oriented Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66
Artificial Intelligence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69
Sprites and Performance Boosting Tricks . . . . . . . . . . . . . . . . . . . . . . . .76
The Game Proposal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84
The Game Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86
The Coding Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99
Adding the Final Touches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
vii
4010fm.qxd 8/20/04 2:33 PM Page viii

Contents

Chapter 3 Managed DirectX First Steps: Direct3D


Basics and DirectX vs. GDI+ . . . . . . . . . . . . . . . . 141
DirectX Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142
3-D Coordinate Systems and Projections . . . . . . . . . . . . . . . . . . . . . . . .153
Drawing Primitives and Texture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .160
The Application Proposal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .168
The Application Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169
The Coding Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170
Adding the Final Touches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203
More About DirectX and GDI+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206

Chapter 4 Space Donuts: Sprites Revisited . . . . . . . . . . . 207

Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .208
Space Donuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .223
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243

Chapter 5 Spacewar! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245


About Spacewar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .246
Methodology: Challenges of Working with
Someone Else’s Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .248
Using the Application Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .248
Direct Play . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .261
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .269
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .269

Chapter 6 Spacewar3D: Meshes and Buffers


and Textures, Oh My! . . . . . . . . . . . . . . . . . . . . . . . . . . 271
DirectX Basics: The Application Wizard Revisited . . . . . . . . . . . . .272
Spacewar3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .284
The Game Proposal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .285
The Game Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .285
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .326
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .326

viii
4010fm.qxd 8/20/04 2:33 PM Page ix

Contents

Chapter 7 Adding Visual Effects to Spacewar3D . . . . . 327

Point Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .327


Step 10: Adding Thrust Effects to Spacewar3D . . . . . . . . . . . . . . . . .329
Step 11: Adding Explosion Effects to Spacewar3D . . . . . . . . . . . . . .337
Step 12: Adding a Shockwave Effect to Spacewar3D . . . . . . . . . . . .339
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .341

Epilogue Taking Your Next Steps . . . . . . . . . . . . . . . . . . . . . . . . 343

Moving On . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .343
Habits to Build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .344
Things We Neglected to Tell You . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .348
Happy Trails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .350

Bonus Chapter Porting .Nettrix to Pocket PC . . . . . . . . 351

Programming for Mobile Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .352


The Game Proposal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .356
The Game Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .357
The Coding Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .358
Adding the Final Touches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .368
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .369

Appendix A Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371

Appendix B Motivations in Games . . . . . . . . . . . . . . . . . . . . . . . . . 375

Appendix C How Do I Make Games? . . . . . . . . . . . . . . . . . . . . . . . . 381

Appendix D Guidelines for Developing


Successful Games . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399

ix
4010fm.qxd 8/20/04 2:33 PM Page xi

Foreword
BACK A FEW YEARS AGO I HAD AN IDEA. What if I could make the power of the
DirectX API available to the developers who were going to be using the new set
of languages and common language runtime that Microsoft was developing?
The idea was intriguing, and opening up a larger portion of the world to DirectX
was a goal I was only happy to endorse. Besides, what developer doesn’t want to
write games?
It seems that at least once a week I am answering questions directly regard-
ing the performance of managed code, and Managed DirectX in particular. One
of the more common questions I hear is some paraphrase of “Is it as fast as
unmanaged code?”
Obviously in a general sense it isn’t. Regardless of the quality of the Managed
DirectX API, the fact remains that it still has to run through the same DirectX API
that the unmanaged code does. There is naturally going to be a slight overhead
for this, but does it have a large negative impact on the majority of applications?
Of course it doesn’t. No one is suggesting that one of the top-of-the-line polygon
pushing games coming out today (say, Half Life 2 or Doom 3) should be written
in Managed DirectX, but that doesn’t mean that there isn’t a whole slew of games
that could be. I’ll get more to that in just a few moments.
The reality is that many of the developers out there today simply don’t know
how to write well-performing managed code. This isn’t through any shortcoming
of these developers, but rather the newness of the API, combined with not enough
documentation on performance, and how to get the best out of the CLR. For the
most part, we’re all new developers in this area, and things will only get better as
people come to understand the process.
It’s not at all dissimilar to the change from assembler to C code for games.
It all comes down to a simple question: Do the benefits outweigh the negatives?
Are you willing to sacrifice a small bit of performance for the easier development
of managed code? The quicker time to market? The greater security? The easier
debugging? Are you even sure that you would see a difference in performance?
Like I mentioned earlier, there are certain games today that aren’t good fits
for having the main engine written in managed code, but there are plenty of
titles that are. The top ten selling PC games just a few months ago included two
versions of the Sims, Zoo Tycoon (+ expansion), Backyard Basketball 2004, and
Uru: Ages Beyond Myst, any of which could have been written in managed code.
Anyone who has taken the time to write some code in one of the managed
languages normally realizes the benefits the platform offers pretty quickly. Using

xi
4010fm.qxd 8/20/04 2:33 PM Page xii

Foreword

this book, you should be able to pick up the beginning concepts of game devel-
opment pretty easily. It takes you through the simple sprite-based games, all the
way through a basic 3-D game implementation.
It’s an exciting time to be a developer.
Tom Miller
Lead Developer for the Managed DirectX Library,
Microsoft Corporation

xii
4010fm.qxd 8/20/04 2:33 PM Page xiii

About the Authors


Somewhere around 1974, David Weller discovered a coin-operated Pong game
in a pizza parlor in Sacramento, California, and was instantly hooked on com-
puter games. A few years later, he was introduced to the world of programming
by his godfather, who let him use his Radio Shack TRS-80 computer to learn
about programming in BASIC. David’s first program was a simple dice game that
graphically displayed the die face (he still has the first version he originally wrote
on paper). He quickly outgrew BASIC though, and soon discovered the amazing
speed you could get by writing video games in assembly language. He spent the
remainder of his high school years getting bad grades, but writing cool software,
none of which made him any money. He spent the next 10 years in the military,
learning details about computer systems and software development. Shortly
after he left the military, David was offered a job to help build the Space Station
Training Facility at NASA. From that point on, he merrily spent time working on
visual simulation and virtual reality applications. He made the odd shift into
multitier IT application development during the Internet boom, ultimately land-
ing inside of Microsoft as a technical evangelist, where he spends time playing
with all sorts of new technology and merrily saying under his breath, “I can’t
believe people pay me to have this much fun!”

Alexandre Santos Lobão got his first computer in 1981, when he was 12, and
immediately started to create simple games in BASIC. Since then, computers
have evolved massively, and so has he. Graduating with a bachelor’s degree in
computer science in 1991, Alexandre, together with six friends, founded that
same year a company that came to be known as a synonym for high-quality
services in Brasilia, Brazil: Hepta Informática.
Besides his excellent work in many software development areas, from
financial to telecommunication, he never forgot his first passion, and has always
worked as a nonprofessional game programmer. From 1997 to 1999 he also
worked at Virtually Real (http://www.vrealware.com), a virtual Australian amateur
game programming company founded by Craig Jardine.
At the end of 2000, Alexandre started searching for new horizons and,
leaving the company he helped to create, entered Microsoft as a consultant.
Looking at the new and extremely interesting possibilities offered by the .NET
Framework, he decided to take everything he’s learned over the last decade
and apply it to this new development platform.

xiii
4010fm.qxd 8/20/04 2:33 PM Page xiv

About the Authors

Ellen Hatton is a computer science undergraduate at Edinburgh University. She


was exposed to computers at a very early age and has been fascinated with them
ever since. Her first experience with computer games was playing Dread Dragon
Doom, at which she quickly excelled at the age of 5. She’s been hooked on games
ever since.
Ellen is not only interested in computers. She skis frequently, amongst other
sports, and enjoys general student life in the bustling Scottish capital,
Edinburgh.
As her choice of degree suggests, Ellen still finds computers very interesting
and is constantly looking for new challenges. This book is the latest.

xiv
4010fm.qxd 8/20/04 2:33 PM Page xv

About the Technical


Reviewer
Andrew Jenks began writing code when his parents bought him a TI 99-4A for a
Christmas present. As tape drives were hard to use, and the media resulting was
often overwritten by singing siblings, his father brought home their first family
computer in 1985. Andrew learned to write BASIC and assembly programs
through old Sanyo manuals and whatever he could find in the library. This
proved handy when he found himself broke at the Georgia Institute of
Technology and discovered that people would pay him to teach computing
classes. He went on to act as a developer for an artificial intelligence company,
manager for a communication company at the 1996 Olympics, and a technical
advisor for several political campaigns. Andrew joined Microsoft as a program
manager in 2000 and can currently be found working on MSJVM migration
issues when he’s not off skiing or diving.
During Andrew’s illustrious career as a professional geek, he has written
code that caused several graphics cards to make pretty blue sparks, lost one
monitor due to a long fall, and set one machine on fire. He is most proud of the
fire. That was good code.

xv
4010fm.qxd 8/20/04 2:33 PM Page xvi

Credits
Figure 6-13: Serious Sam® ©2001 is a trademark of Croteam Ltd.
All rights reserved.

Figure C-1: Quake® is a trademark of Id Software, Inc. All rights reserved.

Figure C-4: PAC-MAN® ©1980 Namco Ltd. All rights reserved. Courtesy
of Namco Holding Corp.

Figure C-5: Super Mario Bros. 2® © 1988 by Nintendo of America Inc.

Figure C-6: GALAGA® ©1980 Namco Ltd. All rights reserved. Courtesy of
Namco Holding Corp.

Figure C-7: GAUNTLET® DARK LEGACY™ © 1998–2000 Midway Games


West Inc. GAUNTLET DARK LEGACY is a trademark of Midway Games
West Inc.

xvi
4010fm.qxd 8/20/04 2:33 PM Page xvii

Acknowledgments

Tools and Tunes

To begin with, no development effort can be done without tools. There tools
were invaluable to me, and I heartily recommend them as “must have” tools:

• IDE: Visual Studio .NET Professional 2003 (http://www.microsoft.com/


catalog/display.asp?subid=22&site=11513&x=30&y=4)

• Source control: SourceGear’s Vault (http://www.sourcegear.com/vault)

• DirectX 9 SDK (http://www.microsoft.com/directx)

I also want to thank those that kept me rocking while typing: Prodigy,
Ghetto Boys, Radiohead, Everclear, AC/DC, Christopher Parkening, Elliot Fisk,
Jimmy Buffett, Fleetwood Mac, the cast of the movie Chicago, Shakira, Norah
Jones, Alejandro Sanz, Juanes, and many, many more.

People Who Really Made This Happen


Few authors can write a book completely by themselves, and I’m no exception
to this rule. First and foremost, this book could not have been done without the
coding wisdom of Scott Haynie. He converted the Spacewar game and wrote the
bulk of the code for the Spacewar3D game. In addition, he gladly contributed the
3-D models for the Spacewar3D game. This book would have been very different
without his help and ideas, and he has my undying gratitude.
In addition, other people helped by contributing code or offering sugges-
tions. Tristian Cartony (.Nettrix), Stephen Toub (.Netterpillars), Carole Snyder,
and Franklin Munoz. For anybody else who contributed that I forgot to call out
by name, please accept my apologies in advance.
There are two other people I’d especially like to thank: Tom Miller, the prin-
cipal developer of the Managed DirectX libraries, graciously whacked me over
the head several times saying, “What were you thinking?!” Without his (if you’ll
pardon the pun) direct input, we might have taught some beginners some very
bad Managed DirectX habits. And, of course, Sofia Marchant, the project man-
ager for this book, who did a great job of being my “velvet-gloved taskmaster” as
well, making sure I was staying on schedule to get this book done on time.

xvii
4010fm.qxd 8/20/04 2:33 PM Page xviii

Acknowledgments

Lastly on the list are the people who have quietly (or not-so-quietly) influ-
enced this book:

• My godfather, Charles Plott, who opened up my eyes to the world of com-


puters and computer games.

• My high school math teacher, Duane Peterson, who let me take a com-
puter programming class in spite of not knowing enough math—the result
of which inspired me to get a degree in computer science with a math
minor.

• My mom and dad, who put up with my intense passion for computers
during my adolescence, in spite of not having enough money to buy me
the mainframe system I wanted to put in our garage.

• My kids, Erich and Gretchen, and their mother, Nancy, who patiently
tolerated my passion for computer games for many years.

Lastly, I want to thank my girlfriend Ana, who has made some very gloomy
days for me much brighter, and who gave me all the support she could, even
though she was 2000 miles away most of the time.
—David Weller

xviii
4010fm.qxd 8/20/04 2:33 PM Page xix

Preface
I APPROACHED ALEXANDRE ABOUT A YEAR AGO to offer him comments on his first
book, .NET Game Programming with DirectX 9.0. After presenting him with a
rather long list of what I would have done differently, Alex graciously suggested
collaborating on a new book. We decided early in the process to reuse some
of the game examples from his book (specifically .Nettrix and .Netterpillars),
although some parts have been heavily modified. We did this for two reasons:

• The games are good, simple examples that can stand the test of time when
it comes to learning game programming. There was no sense creating a
different game just to convey the same concept.

• Writing different games from scratch would take time away from adding
newer games at the end of the book that challenged the beginner.

Of course, my youthful memories of the early computer games influenced


me to choose a space theme for the later games, leaning on the well-known
games of Asteroids and Spacewar. But I wanted to take things a step further, to
show how 2-D gaming knowledge can quickly scale into 3-D games. I had never
seen a book take such a step, and was frankly worried that it couldn’t be done
effectively. However, the book you’re holding is the best attempt I can put for-
ward, and hopefully you’ll find the progression simple as well as instructional.
Due to my distaste for gaming books that double as gymnasium free
weights, I wanted to create a book that avoided the long, pointless chapters that
explained Visual Basic .NET (henceforth referred to as “VB”), object-oriented
programming, how to use Visual Studio, etc. This book gets right to the games,
and assumes you have a rudimentary knowledge of VB. If you need to get up to
speed on VB, we recommend Matthew Tagliaferri’s Learn VB .NET Through
Game Programming (Apress, ISBN 1-59059-114-3), which makes an excellent
companion book to this one.
For developers who are already familiar with programming and basic gaming
concepts, this book will serve well as a high-speed introduction to Visual Basic
.NET and, in later chapters, Managed DirectX. If you’re already intimately familiar
with DirectX game development and are looking for a book focused directly on
Managed DirectX, I recommend Managed DirectX Kick Start (SAMS, 2003) written
by Tom Miller. Of course, I would love for you to buy this book as well, but I’m
more interested in getting you to write games in Managed DirectX than I am in
making a buck or two by convincing you to buy this book.

xix
Another Random Document on
Scribd Without Any Related Topics
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.

Project Gutenberg™ eBooks are often created from several printed


editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like