简介
Do you love video games? Ever wondered if you could create one of your own, with all the bells and whistles? It's not as complicated as you'd think, and you don't need to be a math whiz or a programming genius to do it. In fact, everything you need to create your first game, "Invasion of the Slugwroths," is included in this book and CD-ROM. Author David Conger starts at square one, introducing the tools of the trade and all the basic concepts for getting started programming with C++, the language that powers most current commercial games. Plus, he's put a wealth of top-notch (and free) tools on the CD-ROM, including the Dev-C++ compiler, linker, and debugger--and his own LlamaWorks2D game engine. Step-by-step instructions and ample illustrations take you through game program structure, integrating sound and music into games, floating-point math, C++ arrays, and much more. Using the sample programs and the source code to run them, you can follow along as you learn. Bio: David Conger has been programming professionally for over 23 years. Along with countless custom business applications, he has written several PC and online games. Conger also worked on graphics firmware for military aircraft, and taught computer science at the university level for four years. Conger has written numerous books on C, C++, and other computer-related topics. He lives in western Washington State and has also published a collection of Indian folk tales.
目录
Table Of Contents:
Introduction xix
What's Different About This Book xx
It doesn't assume you know how to program computers xx
It teaches you real game programming skills xxi
It teaches you how to build a real game xxi
It provides everything you need to write games xxii
Both teens and adults can use this book xxii
What's in This Book? xxiii
System Requirements xxiii
Free Stuff on the CD xxiv
Installation instructions xxv
Compiling the sample programs xxv
Who Am I? xxvi
PART 1 THE REALLY BASIC STUFF
What It takes to Be a Game Programmer 3(22)
Programming Skills 4(7)
What is a computer program? 4(2)
The C++ programming language 6(1)
Tools of the trade 6(1)
Compilers 6(1)
Linkers 7(1)
Debuggers 8(1)
Graphics libraries 8(1)
Game engines 9(2)
Computer Graphics Skills 11(5)
The basics of computer graphics 11(1)
How computer monitors work 11(1)
Selecting graphics modes 12(1)
Displaying pictures on a computer monitor 13(1)
Animating your game 14(2)
Game Design Skills 16(5)
Structuring game code 16(1)
Making games good 16(1)
Make it unique 17(1)
Make it plausible 18(1)
Make it playable 18(1)
Make the player think 19(2)
Art Skills 21(1)
Sound and Music Skills 22(2)
Summary 24(1)
Writing C++ Programs 25(38)
Introducing the Dev-C++ Compiler 26(5)
Creating a project 27(2)
Writing programs 29(2)
Compiling and linking programs 31(1)
Programming in C++ 31(25)
The main() thing 31(2)
Variables 33(3)
Output to the screen 36(1)
Input from the keyboard 37(1)
Streams and include statements 38(1)
Functions 39(2)
Creating functions 41(1)
Passing values to functions 41(1)
The body of a function 42(1)
Returning values from functions 42(1)
Scope in functions 43(1)
Prototypes 44(1)
A few final words about Listing 2.3 45(2)
Essential math operators 47(1)
Addition, subtraction, multiplication, and division 47(3)
Increment and decrement operators 50(1)
Loops 51(1)
while loops 52(2)
do-while loops 54(2)
Windows Programming 56(1)
WinMain() 56(1)
Messages and message processing 57(1)
Game Programming 57(3)
What is OpenGL? 57(1)
What is OpenAL? 58(1)
OpenGL, OpenAL, and DirectX 59(1)
Summary 60(3)
PART 2 OBJECT-ORIENTED PROGRAMMING IN GAMES
Introducing Object-Oriented Programming 63(30)
Software Objects 64(1)
Classes 65(17)
Member data 66(2)
Member functions 68(4)
Constructors and destructors 72(4)
Inline member functions 76(6)
Logical Operators 82(3)
The if-else Statement 85(2)
Namespaces and Scope Resolution 87(4)
A Brief Word About Structures 91(1)
Summary 92(1)
Introducing the LlamaWorKs2D Game Engine 93(24)
A Step-by-Step Overview 94(5)
Phase 1: Create a Dev-C++ project 94(1)
Phase 2: Configure the Dev-C++ project 95(2)
Phase 3: Write a game class 97(2)
Phase 4: Compile and run the program 99(1)
How Does LlamaWorks2D Work? 99(2)
A Stationary Ball 101(5)
A Bouncing Ball 106(8)
Getting Good Results 114(1)
Summary 115(2)
Function and Operator Overloading 117(28)
What Is Overloading? 118(4)
Overloading functions 118(3)
Overloading operators 121(1)
Implementing a Vector Class with Overloading 122(21)
Overloaded vector constructors 125(1)
Addition and subtraction of vectors 126(3)
Multiplication of vectors 129(1)
Multiplying vectors by scalars 129(1)
Multiplying scalars by vectors with friend functions 130(2)
The dot product 132(2)
Division of vectors 134(2)
Operator-equals operators 136(5)
Magnitude 141(1)
Unit vectors 142(1)
Summary 143(2)
Inheritance: Getting a Lot for a Little 145(20)
What Is Inheritance? 146(2)
Deriving Classes 148(5)
Protected Members 153(4)
Overriding Base Class Functions 157(3)
Customizing Your Game with Inheritance 160(1)
Summary 161(4)
PART 3 THE ESSENTIALS OF GAME DEVELOPMENT
Program Structure 165(40)
Program Structure 166(3)
Designing game objects 166(2)
Designing game tasks 168(1)
File Structure 169(1)
A Game Called Ping 170(33)
Introducing Ping 170(1)
Writing Ping 170(1)
Creating the game's objects 171(3)
Mapping other Windows messages 174(5)
Initializing the program 179(2)
Initializing the game 181(5)
Initializing a level 186(3)
Handling messages 189(2)
Updating a frame 191(8)
Rendering a frame 199(2)
Cleaning up a level 201(1)
Cleaning up the game 201(2)
Summary 203(2)
Sound Effects and Music 205(26)
Sound Effects and Music Are Emotion 206(1)
Storing Sound Data 207(3)
Digitized sound 207(1)
MIDI files 208(1)
Sound storage techniques compared 209(1)
Sound Effects in LlamaWorks2D 210(12)
Loading sounds 212(2)
Playing sounds 214(2)
Adding background music 216(4)
Controlling the volume 220(2)
Noise, Sweet Noise 222(2)
Finding sound effects 222(1)
Making your own sound effects 223(1)
Using real-world sounds 223(1)
Generating sounds on an electronic keyboard 223(1)
Using sound effects-generation software 223(1)
Play That Funky Music, Geek Boy 224(4)
Finding music 224(1)
Making your own music 224(1)
Band-in-a-box programs 224(1)
Loop-based programs 225(1)
MIDI instruments 226(1)
Other instruments and tools 227(1)
Summary 228(3)
PART 4 GRADUATING TO BETTER C++
Floating-Point Math in C++ 231(32)
Getting into the Guts of Floating-Point Numbers 232(3)
Floating-point numbers and precision errors 234(1)
Floating-point numbers and rounding errors 235(1)
Case Study: Floating-Point Numbers and Gamespaces 235(27)
What is a gamespace? 236(2)
Writing a vector class that uses floating-point numbers 238(1)
CannonShoot: A gamespace in action 239(1)
Introducing the cannonshoot class 240(2)
Implementing the cannonshoot class 242(1)
Initializing a cannonshoot object 242(3)
Updating and rendering a frame 245(2)
Converting floating-point gamespace coordinates to integer screen coordinates 247(1)
Creating a cannonball 248(1)
Design considerations for the cannonball class 248(4)
Simulating a cannonball in flight 252(4)
Creating a cannon 256(2)
Arming and firing the cannon 258(3)
Updating and rendering a cannon 261(1)
Summary 262(1)
Arrays 263(14)
What Are Arrays? 264(1)
Declaring and Using Arrays 264(9)
2D arrays 268(3)
3D arrays 271(2)
Initializing Arrays 273(2)
Problems with Array Boundaries 275(1)
Summary 276(1)
Pointers 277(22)
Why Are Pointers Important to Games? 278(1)
Declaring and Using Pointers 278(4)
Pointers and Dynamic Memory Allocation 282(10)
Allocating memory 283(5)
Freeing memory 288(4)
Pointers and Inheritance 292(4)
Arrays Are Pointers in Disguise 296(2)
Summary 298(1)
File Input and Output 299(18)
Games and File I/O 300(1)
Types of Files 301(15)
Text files 301(1)
Writing to Text Files 301(4)
Reading from Text Files 305(3)
Binary files 308(1)
Writing to Binary Files 308(5)
Reading from Binary Files 313(3)
Summary 316(1)
Moving Into Real Game Development 317(20)
Sprites That Come Alive 318(11)
Sprites and animation frames 318(1)
Animated sprites in LlamaWorks2D 319(1)
CannonShoot revisited 320(9)
High-Speed Input 329(5)
Introducing immediate mode input 330(1)
Ping and immediate mode input 331(3)
Summary 334(3)
PART 5 THE BIG PAYOFF
No Slime Allowed: Invasion of the Slugwroths 337(16)
What It Takes to Make a Real Game 338(2)
Essential Game Design 340(9)
Elements of good game design 340(1)
Training the player during gameplay 340(1)
Keeping it fresh with new challenges 341(1)
Keeping challenges appropriate 341(1)
Incorporating power-ups for player relief 342(1)
Deciding when to use a boss 342(1)
The game design process 342(1)
Start with a brainstorming session 343(1)
Create the goal for the game 344(1)
Select the emotional experience for the game 344(1)
Choose the right look 345(1)
Set the hook 345(2)
Create a design document 347(1)
Let it simmer a while 348(1)
Revise the design document 348(1)
Create a prototype and play it 348(1)
Iterate as necessary 349(1)
Designing Invasion of the Slugwroths 349(3)
The brainstorm 349(2)
The goal 351(1)
The experience 351(1)
The look 351(1)
The hooks 351(1)
The design document 352(1)
Summary 352(1)
Captain Chloride Gets Going 353(14)
Introducing Captain Chloride 354(8)
Designing the chloride class 355(2)
Implementing the chloride class 357(5)
Pulling It Together in the Game Class 362(4)
Summary 366(1)
The World of Captain Chloride 367(22)
The New Captain Chloride 368(5)
Levels in LlamaWorks2D 373(14)
XML level files 374(3)
A level file for Invasion of the Slugwroths 377(1)
Parsing level files 378(4)
Loading a level 382(2)
Updating a level 384(1)
Rendering a level 385(2)
Summary 387(2)
Captain Chloride Encounters Solid Objects 389(18)
Bumping into a Solid Door 390(7)
Collision management 390(2)
A basic door 392(1)
The very collidable Captain Chloride 393(2)
Captain Chloride collides with reality 395(2)
Picking Up a Key 397(3)
Objects that can be picked up 397(2)
Making Captain Chloride pick things up 399(1)
Making the Door Open and Close 400(6)
Adventures in two and a half dimensions 401(2)
Two and a half dimensional programming in action 403(3)
Summary 406(1)
That's a Wrap! 407(12)
Time for Consolidation 408(1)
Enter Villains, Stage Left 409(6)
Designing a simple Slugwroth 409(1)
Implementing the Slugwroth class 410(5)
Additions to the Game 415(2)
Epilogue: Not the End 417(2)
Glossary 419(6)
Index 425
Introduction xix
What's Different About This Book xx
It doesn't assume you know how to program computers xx
It teaches you real game programming skills xxi
It teaches you how to build a real game xxi
It provides everything you need to write games xxii
Both teens and adults can use this book xxii
What's in This Book? xxiii
System Requirements xxiii
Free Stuff on the CD xxiv
Installation instructions xxv
Compiling the sample programs xxv
Who Am I? xxvi
PART 1 THE REALLY BASIC STUFF
What It takes to Be a Game Programmer 3(22)
Programming Skills 4(7)
What is a computer program? 4(2)
The C++ programming language 6(1)
Tools of the trade 6(1)
Compilers 6(1)
Linkers 7(1)
Debuggers 8(1)
Graphics libraries 8(1)
Game engines 9(2)
Computer Graphics Skills 11(5)
The basics of computer graphics 11(1)
How computer monitors work 11(1)
Selecting graphics modes 12(1)
Displaying pictures on a computer monitor 13(1)
Animating your game 14(2)
Game Design Skills 16(5)
Structuring game code 16(1)
Making games good 16(1)
Make it unique 17(1)
Make it plausible 18(1)
Make it playable 18(1)
Make the player think 19(2)
Art Skills 21(1)
Sound and Music Skills 22(2)
Summary 24(1)
Writing C++ Programs 25(38)
Introducing the Dev-C++ Compiler 26(5)
Creating a project 27(2)
Writing programs 29(2)
Compiling and linking programs 31(1)
Programming in C++ 31(25)
The main() thing 31(2)
Variables 33(3)
Output to the screen 36(1)
Input from the keyboard 37(1)
Streams and include statements 38(1)
Functions 39(2)
Creating functions 41(1)
Passing values to functions 41(1)
The body of a function 42(1)
Returning values from functions 42(1)
Scope in functions 43(1)
Prototypes 44(1)
A few final words about Listing 2.3 45(2)
Essential math operators 47(1)
Addition, subtraction, multiplication, and division 47(3)
Increment and decrement operators 50(1)
Loops 51(1)
while loops 52(2)
do-while loops 54(2)
Windows Programming 56(1)
WinMain() 56(1)
Messages and message processing 57(1)
Game Programming 57(3)
What is OpenGL? 57(1)
What is OpenAL? 58(1)
OpenGL, OpenAL, and DirectX 59(1)
Summary 60(3)
PART 2 OBJECT-ORIENTED PROGRAMMING IN GAMES
Introducing Object-Oriented Programming 63(30)
Software Objects 64(1)
Classes 65(17)
Member data 66(2)
Member functions 68(4)
Constructors and destructors 72(4)
Inline member functions 76(6)
Logical Operators 82(3)
The if-else Statement 85(2)
Namespaces and Scope Resolution 87(4)
A Brief Word About Structures 91(1)
Summary 92(1)
Introducing the LlamaWorKs2D Game Engine 93(24)
A Step-by-Step Overview 94(5)
Phase 1: Create a Dev-C++ project 94(1)
Phase 2: Configure the Dev-C++ project 95(2)
Phase 3: Write a game class 97(2)
Phase 4: Compile and run the program 99(1)
How Does LlamaWorks2D Work? 99(2)
A Stationary Ball 101(5)
A Bouncing Ball 106(8)
Getting Good Results 114(1)
Summary 115(2)
Function and Operator Overloading 117(28)
What Is Overloading? 118(4)
Overloading functions 118(3)
Overloading operators 121(1)
Implementing a Vector Class with Overloading 122(21)
Overloaded vector constructors 125(1)
Addition and subtraction of vectors 126(3)
Multiplication of vectors 129(1)
Multiplying vectors by scalars 129(1)
Multiplying scalars by vectors with friend functions 130(2)
The dot product 132(2)
Division of vectors 134(2)
Operator-equals operators 136(5)
Magnitude 141(1)
Unit vectors 142(1)
Summary 143(2)
Inheritance: Getting a Lot for a Little 145(20)
What Is Inheritance? 146(2)
Deriving Classes 148(5)
Protected Members 153(4)
Overriding Base Class Functions 157(3)
Customizing Your Game with Inheritance 160(1)
Summary 161(4)
PART 3 THE ESSENTIALS OF GAME DEVELOPMENT
Program Structure 165(40)
Program Structure 166(3)
Designing game objects 166(2)
Designing game tasks 168(1)
File Structure 169(1)
A Game Called Ping 170(33)
Introducing Ping 170(1)
Writing Ping 170(1)
Creating the game's objects 171(3)
Mapping other Windows messages 174(5)
Initializing the program 179(2)
Initializing the game 181(5)
Initializing a level 186(3)
Handling messages 189(2)
Updating a frame 191(8)
Rendering a frame 199(2)
Cleaning up a level 201(1)
Cleaning up the game 201(2)
Summary 203(2)
Sound Effects and Music 205(26)
Sound Effects and Music Are Emotion 206(1)
Storing Sound Data 207(3)
Digitized sound 207(1)
MIDI files 208(1)
Sound storage techniques compared 209(1)
Sound Effects in LlamaWorks2D 210(12)
Loading sounds 212(2)
Playing sounds 214(2)
Adding background music 216(4)
Controlling the volume 220(2)
Noise, Sweet Noise 222(2)
Finding sound effects 222(1)
Making your own sound effects 223(1)
Using real-world sounds 223(1)
Generating sounds on an electronic keyboard 223(1)
Using sound effects-generation software 223(1)
Play That Funky Music, Geek Boy 224(4)
Finding music 224(1)
Making your own music 224(1)
Band-in-a-box programs 224(1)
Loop-based programs 225(1)
MIDI instruments 226(1)
Other instruments and tools 227(1)
Summary 228(3)
PART 4 GRADUATING TO BETTER C++
Floating-Point Math in C++ 231(32)
Getting into the Guts of Floating-Point Numbers 232(3)
Floating-point numbers and precision errors 234(1)
Floating-point numbers and rounding errors 235(1)
Case Study: Floating-Point Numbers and Gamespaces 235(27)
What is a gamespace? 236(2)
Writing a vector class that uses floating-point numbers 238(1)
CannonShoot: A gamespace in action 239(1)
Introducing the cannonshoot class 240(2)
Implementing the cannonshoot class 242(1)
Initializing a cannonshoot object 242(3)
Updating and rendering a frame 245(2)
Converting floating-point gamespace coordinates to integer screen coordinates 247(1)
Creating a cannonball 248(1)
Design considerations for the cannonball class 248(4)
Simulating a cannonball in flight 252(4)
Creating a cannon 256(2)
Arming and firing the cannon 258(3)
Updating and rendering a cannon 261(1)
Summary 262(1)
Arrays 263(14)
What Are Arrays? 264(1)
Declaring and Using Arrays 264(9)
2D arrays 268(3)
3D arrays 271(2)
Initializing Arrays 273(2)
Problems with Array Boundaries 275(1)
Summary 276(1)
Pointers 277(22)
Why Are Pointers Important to Games? 278(1)
Declaring and Using Pointers 278(4)
Pointers and Dynamic Memory Allocation 282(10)
Allocating memory 283(5)
Freeing memory 288(4)
Pointers and Inheritance 292(4)
Arrays Are Pointers in Disguise 296(2)
Summary 298(1)
File Input and Output 299(18)
Games and File I/O 300(1)
Types of Files 301(15)
Text files 301(1)
Writing to Text Files 301(4)
Reading from Text Files 305(3)
Binary files 308(1)
Writing to Binary Files 308(5)
Reading from Binary Files 313(3)
Summary 316(1)
Moving Into Real Game Development 317(20)
Sprites That Come Alive 318(11)
Sprites and animation frames 318(1)
Animated sprites in LlamaWorks2D 319(1)
CannonShoot revisited 320(9)
High-Speed Input 329(5)
Introducing immediate mode input 330(1)
Ping and immediate mode input 331(3)
Summary 334(3)
PART 5 THE BIG PAYOFF
No Slime Allowed: Invasion of the Slugwroths 337(16)
What It Takes to Make a Real Game 338(2)
Essential Game Design 340(9)
Elements of good game design 340(1)
Training the player during gameplay 340(1)
Keeping it fresh with new challenges 341(1)
Keeping challenges appropriate 341(1)
Incorporating power-ups for player relief 342(1)
Deciding when to use a boss 342(1)
The game design process 342(1)
Start with a brainstorming session 343(1)
Create the goal for the game 344(1)
Select the emotional experience for the game 344(1)
Choose the right look 345(1)
Set the hook 345(2)
Create a design document 347(1)
Let it simmer a while 348(1)
Revise the design document 348(1)
Create a prototype and play it 348(1)
Iterate as necessary 349(1)
Designing Invasion of the Slugwroths 349(3)
The brainstorm 349(2)
The goal 351(1)
The experience 351(1)
The look 351(1)
The hooks 351(1)
The design document 352(1)
Summary 352(1)
Captain Chloride Gets Going 353(14)
Introducing Captain Chloride 354(8)
Designing the chloride class 355(2)
Implementing the chloride class 357(5)
Pulling It Together in the Game Class 362(4)
Summary 366(1)
The World of Captain Chloride 367(22)
The New Captain Chloride 368(5)
Levels in LlamaWorks2D 373(14)
XML level files 374(3)
A level file for Invasion of the Slugwroths 377(1)
Parsing level files 378(4)
Loading a level 382(2)
Updating a level 384(1)
Rendering a level 385(2)
Summary 387(2)
Captain Chloride Encounters Solid Objects 389(18)
Bumping into a Solid Door 390(7)
Collision management 390(2)
A basic door 392(1)
The very collidable Captain Chloride 393(2)
Captain Chloride collides with reality 395(2)
Picking Up a Key 397(3)
Objects that can be picked up 397(2)
Making Captain Chloride pick things up 399(1)
Making the Door Open and Close 400(6)
Adventures in two and a half dimensions 401(2)
Two and a half dimensional programming in action 403(3)
Summary 406(1)
That's a Wrap! 407(12)
Time for Consolidation 408(1)
Enter Villains, Stage Left 409(6)
Designing a simple Slugwroth 409(1)
Implementing the Slugwroth class 410(5)
Additions to the Game 415(2)
Epilogue: Not the End 417(2)
Glossary 419(6)
Index 425
光盘服务联系方式: 020-38250260 客服QQ:4006604884
云图客服:
用户发送的提问,这种方式就需要有位在线客服来回答用户的问题,这种 就属于对话式的,问题是这种提问是否需要用户登录才能提问
Video Player
×
Audio Player
×
pdf Player
×
亲爱的云图用户,
光盘内的文件都可以直接点击浏览哦
无需下载,在线查阅资料!