作者:empty 页数:443 出版社:empty |
A 2011 Course Technology, apart afCon gage Leat ringALL RIG HIS RESERVED.No part of ths work covered by the copy ngh there in maybaro produced, transmitted, stared, or used in any form or by any means graphicelectron k, or mechan kcalindudingbuthotImted to photocopying.re carding,scanning, digitizing.taping, Wob distribution, information net warks, orn foe mation storage andro trieval systems, except aspemmttedunderSection1o 7orToBofthe1976Unitod States Copy ight Act without the prior wrt tenpems sion of the pub is her.VisualStudio 2010 Express Web installer i are gite red trademark ofMicrosoft Corporation in the United States and other countries.Dr Petter.NUnit is a copyright of NUnit org.Bitmap Font Creator is acopyright of andreas jonsson.
ACKNOWLEDGMENTSMany thanks to everyone who has helped with this book and to everyone whodeveloped the wonderful libraries and tools that it uses.Thanks to JennyDavidson, the book's project editor, for all her help making my writing clearer andensuring that everything was finished in time.Thanks to my technical editor, JimPerry, who caught my many coding mistakes and provided valuable suggestionsand advice.I would also like to thank my family and coworkers for their supportand helpful input.
ABOUT THE AUTHORDaniel Schuller is a British-born computer game developer who has workedand lived in the United States, Singapore, Japan, and is currently working inthe United Kingdom.He has released games on the P Caswell as the Xbox 360and PlayStation 3.Schuller has developed games for Sony, Ubisoft, NaughtyDog, RedBull, and Wizards of the Coast, and maintains a game developmentwebsiteathttp:/www.godpatterns.com.Inadditiontodevelopingcomputergames, Schuller also studies Japanese and is interested in Artificial Intelligence,cognition, and the use of games in education.
CONTENTS
PART I
Chapter 1
Chapter 2
vi
Chapter 3
PART I
Chapter 4
Introduction,
BACKGROUND.
The History of C#.
C#Basics.
Versions of C#.
C#2.0,.
Generics.
Anonymous Delegates.
C3.0.
LINQ.
Lambda Functions.
Object Initializers.
Collection Initializers.
Summary.
Introducing OpenGL.
Architecture of OpenGL.
Local Variable Type Inference and Anonymous Types.
C#4.0,.,,1q
Dynamic Objects.14
Optional Parameters and Named Arguments.15
Vertices-The Building Blocks of 3D Graphics.21
The Pipeline.22
OpenGL Is Changing-.24
OpenGL ES.25
Web GL.25
OpenGL and the Graphics Card.25
Shaders-Programs on the Graphics Card.27
The Tao Framework.28
Summary.30
Modern Methods.31
Pragmatic Programming-.31
Game Programming Traps.32
KISS.32
DRY.32
C++.36
Source Control.37
Introducing VisualStudio Express-A Free IDE for C#.
Subversion, an Easy Source Control Solution
vii
Using Source Control.
Unit Testing.
Test Driven Development
Unit Testing inC#.
Summary.
IMPLEMENTATION.
Setup.
A Quick HelloWorld.
VisualStudio Express Tips.
Automatic Refactoring and Code Generation
Renaming.
Creating Functions.
Separating Chunks of Code.
Shortcuts.
Where to Get it.
Installation.
Creating the Repository.
Adding to the Repository.
History.
Extending HelloWorld.
Tao.
NUnit.
Using NUnit with a Projec
Running Tests.
An Example Project.
Summary.
The Game Loop and Graphics.
How Do Games Work?.
A Closer Look at the Game Loop
Implementing a Fast Game Loop inC#
Adding High-Precision Timing.
Graphics.
FullScreen Mode.
Rendering.
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Clearing the Background.
Vertices.
Triangles.
Coloring and Spinning the Triangle.
Summary.
Game Structure.
The Basic Pattern of a Game Object.
Handling Game State.
Game State Demo.
Setting the Scene with Projections.
Form Size and OpenGL Viewport Size.
AspectRatio.-
The Projection Matr.
2D Graphics.
Sprites.
Positioning the Sprite.
Managing Textures with Dev ll
Textured Sprites.
Alpha Blending Sprites.
Color Modulating Sprites.
A Sprite and Renderer Class.
Using the Sprite Class.
Rendering Text.
Font Textures.
FontData.
Parsing the FontData.
Using the CharacterData.
Rendering Text.
Calculating the FPS.
V-Sync and Frame-Rate.
Profiling.
Refining the Text Class-.
Faster Rendering with gl Draw Arrays.
Modifying the Renderer.
Profiling the Batch Draw Method.,
Summary.
Game Math.
Trigonometric Functions.
Plotting a Graph.
Trigonometric Functions for Special Effects.
Vectors.
What Is a Vector?.
The Length Operation.
Vector Equality.
Vector Addition, Subtraction, and Multiplication.
Normal Vectors.
The Dot Product Operation.
The Cross-Product Operation.
Finishing Touches to the Vector Structure.
Two-Dimensional Intersection.
Circles.
Rectangles.
Tweens.
A nOve view of Tweening.
The Tween Class.
Using Tweens.
Matrices.
What Is a Matrix?.
The ld entity Matrix.
Matrix-Matrix and Vector-Matrix Multiplication.
Translating and Scaling.
Rotation.
Inverse.
Matrix Operations on Sprites.
Modifying the Sprite to Use Matrices.
Optimization.
Making the Game Engine.
A New Game Engine Project.
Extending the Game Engine.
Using the Game Engine in a Project.
Multiple Textures.
Adding Sound Support.
Creating SoundFiles.
Developing a Sound Manager
Improving Input.
Wrapping Game Controllers.
Adding Better Mouse Support.
Adding Keyboard Support.
A Simple Side-Scrolling Shooting Game.
A Simple Game.
The First Implementation Pass.
The Start Menu State.
The Inner Game State.
The Game Over State.
Developing the Inner Game.
Moving the Player Character.
Faking Movement with a Scrolling Background.
Adding Some Simple Enemies.
Introducing Simple Weapons.
Damage and Explosions.
Managing Explosions and Enemies
Level Definitions.
Enemy Movement.
Enemy Attacks.
Continuing Iterations.
Creating Your Own Game.
Project Management.
Display Methods.
2D Games.,
3D Games.
Types of Games.
Text Games.
Puzzle Games.
First-Person Shooter Games.
Strategy Games.
Roe-Playing Games