Programming role-playing games with DirectX

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

This book is for programmers who want to go into the specialized field of programming
role-playing games (RPGs). I think RPGs are some of the best games to play.
I also think that RPGs are the hardest to create. Information on RPG game programming
is hard to come by, so to fill that need, I wrote this book.
In this book, I break a role-playing game into its essential components. I take those
components one by one, giving you a detailed look at each and showing you how
to use all of them in your game project.

Author(s): Jim Adams
Series: The Premier Press game development series
Edition: 1
Publisher: Premier Press
Year: 2002

Language: English
Pages: 1105
City: [Indianapolis, Ind.?]

Cover......Page 1
About the Author......Page 8
Contents at a Glance......Page 9
Contents......Page 11
Foreword......Page 37
Introduction......Page 40
Part 1 - An Introduction to Role-Playing Games......Page 44
A World of Role- Playing......Page 46
A Story of Role- Playing......Page 47
The Basic Concepts......Page 49
Pen- and- Paper Games......Page 50
Role- Playing on the Computer......Page 53
The Evolution of Gaming......Page 55
Wrapping Up with a Look into the Future......Page 60
Part 2 - Role-Playing Game Design......Page 62
Exploring RPG Design Elements......Page 64
The Importance of Design Documents......Page 65
Creating Your Design Document......Page 66
The Perfect Design Document......Page 73
RPG Design Aspects......Page 74
Turning to the Technical Side......Page 75
Knowing Your Role......Page 76
Wrapping Up Design......Page 77
Story- Writing Essentials......Page 78
The Art of Telling Stories......Page 79
and the Three Acts......Page 80
Characters......Page 83
Setting Mood and Atmosphere......Page 85
The Point of View......Page 86
Plots, Subplots, and Twists......Page 87
Eight Rules to Writing......Page 89
Six Steps to Writing......Page 90
Writing the Three Drafts......Page 94
Tips for Better Stories......Page 95
Foreshadowing......Page 96
Harnessing Emotion......Page 97
Studying the Greats......Page 98
Applying Stories to Games......Page 99
Breaking Up the Plot......Page 100
Linear and Nonlinear Story Lines......Page 101
Dialogue......Page 102
Wrapping Up Stories......Page 103
Part 3 - Programming Basics......Page 104
Starting with C++......Page 106
Introducing C+ +......Page 107
Moving from C to C+ +......Page 108
Working with Functions......Page 109
Working with Variables......Page 114
New Keywords and Enhancements......Page 118
Classes......Page 121
Class Visibility......Page 123
Class Variables and Functions......Page 124
Using the this Keyword......Page 131
Class Friends......Page 132
Derived Classes......Page 133
Advanced Structures......Page 138
Wrapping Up C+ +......Page 139
Programming with Windows and Application Basics......Page 140
Coding Conventions......Page 142
Working Inside a Window......Page 145
Advanced Features......Page 162
DirectX......Page 175
Understanding the Program Flow......Page 177
Modular Programming......Page 179
Application States......Page 180
Processes......Page 184
Using Data Packaging......Page 187
Testing the Data Package System......Page 189
Building an Application Framework......Page 191
Debugging Your Program......Page 198
Wrapping Up Windows and Application Basics......Page 200
Drawing with DirectX Graphics......Page 202
The Heart of 3-D Graphics......Page 203
Coordinate Systems......Page 205
Constructing Objects......Page 207
Lists, Strips, and Fans......Page 208
Vertex Ordering......Page 209
Transformations......Page 210
Getting Started with DirectX Graphics......Page 211
Direct3D Components......Page 212
Initializing the System......Page 213
Matrix Math......Page 221
Using Vertices......Page 227
Tr ansformations......Page 234
Materials and Colors......Page 240
Clearing the Viewport......Page 241
Rendering Polygons......Page 242
Presenting the Scene......Page 244
Using Texture Maps......Page 245
Loading a Texture......Page 247
Setting the Texture......Page 249
Using Texture Filters......Page 251
Rendering Textured Objects......Page 253
Alpha Blending......Page 254
Drawing with Alpha Blending......Page 255
with Alpha Testing......Page 256
Lighting......Page 260
Using Spotlights......Page 263
Using Directional Lights......Page 265
Setting the Light......Page 266
Using Normals......Page 267
Using Fonts......Page 270
Creating the Font......Page 271
Drawing with Fonts......Page 273
Billboards......Page 274
Particles......Page 276
Depth Sorting and Z- Buffering......Page 280
Working with Viewports......Page 283
The . X Files......Page 284
Meshes with D3DX......Page 291
Using 3-D Animation . X Style......Page 298
Wrapping Up Graphics......Page 302
Interacting with DirectInput......Page 304
Introducing Input Devices......Page 305
Interacting via the Keyboard......Page 306
Playing with the Mouse......Page 308
Jammin with the Joystick......Page 309
Using DirectInput......Page 311
Presenting DirectInput Basics......Page 312
Initializing DirectInput......Page 313
Employing DirectInput Devices......Page 314
Obtaining a Device GUID......Page 315
Creating the Device COM Object......Page 319
Setting the Cooperative Level......Page 320
Setting Special Properties......Page 321
Acquiring the Device......Page 323
Reading In Data......Page 325
Using DirectInput with the Keyboard......Page 326
Using DirectInput with the Mouse......Page 328
Using DirectInput with Joysticks......Page 330
Wrapping Up Input......Page 334
Playing Sound with DirectX Audio......Page 336
Sound Basics......Page 337
Recording Digital Sounds......Page 338
Musical Madness......Page 339
Using DirectSound......Page 341
Initializing DirectSound......Page 343
Cooperative Level......Page 344
Setting the Playback Format......Page 345
Primary Sound Buffer......Page 350
Using Secondary Sound Buffers......Page 351
Sound Data into the Buffer......Page 353
and Frequency Settings......Page 356
Losing Focus......Page 359
Notifications......Page 360
Using Threads for Events......Page 364
Loading Sounds into the Buffers......Page 366
Streaming Sound......Page 370
Working with DirectMusic......Page 372
Starting with DirectMusic......Page 373
Creating the Performance Object......Page 375
Creating the Loader Object......Page 376
Working with Music Segments......Page 377
Altering Music......Page 387
Finishing Up Sound......Page 392
Networking with DirectPlay......Page 394
Understanding Networking......Page 395
Network Models......Page 396
Communication Protocols......Page 398
Addressing......Page 399
Introducing DirectPlay......Page 400
The Network Objects......Page 401
Networking with Messages......Page 402
From Small Bytes to Big Words......Page 406
Initializing a Network Object......Page 407
Initializing the Address Object......Page 410
Adding Components......Page 411
Selecting a Port......Page 413
Assigning a Device......Page 414
Using Message Handlers......Page 417
Server Session Data......Page 419
Client Session Data......Page 420
Working with Servers......Page 421
Handling Players......Page 424
Receiving Data......Page 429
Sending Server Messages......Page 430
Ending the Host Session......Page 433
Working with Clients......Page 434
Terminating the Client Session......Page 439
Wrapping Up Networking......Page 440
Creating the Game Core......Page 442
Understanding the Core Concept......Page 443
The System Core......Page 444
Using the cApplication Core Object......Page 445
with cStateManager......Page 448
Processes and cProcessManager......Page 451
The Graphics Core......Page 453
The Graphics System with cGraphics......Page 454
Images with cTexture......Page 458
Colors and cMaterial......Page 460
Light It Up with cLight......Page 461
Text and Fonts Using cFont......Page 463
Vertices and cVertexBuffer......Page 465
with cWorldPosition......Page 468
View Transformations and cCamera......Page 470
Loadable Meshes using cMesh......Page 473
Drawing Objects Using cObject......Page 474
Move with cAnimation......Page 477
The Input Core......Page 479
Input Devices with cInputDevice......Page 480
Using the Input Core......Page 483
Control with cSound......Page 484
Using Wave Data and cSoundData......Page 487
with cSoundChannel......Page 490
with cMusicChannel......Page 493
Instruments with cDLS......Page 495
with cNetworkAdapter......Page 497
Servers with cNetworkServer......Page 498
and cNetworkClient......Page 502
Wrapping Up the Game Core......Page 505
Part 4 - Role- Playing Game Programming......Page 508
Using 2-D Graphics......Page 510
Understanding Tiles and Maps......Page 511
Tile Graphics......Page 512
Using Tiles with DirectX......Page 513
Building a Tile- Handler Class......Page 517
Using the Tile Class......Page 525
Drawing Basic Maps......Page 526
Using Multiple Layers......Page 527
Adding Objects......Page 528
Smooth Scrolling......Page 529
The Map and the Mouse......Page 532
Creating a Map Class......Page 533
Angled Tile Engine......Page 540
Big Bitmap Engines......Page 541
A Big Example......Page 542
Wrapping Up 2-D Graphics......Page 543
Creating 3-D Graphics Engines......Page 544
Meshes as Levels......Page 545
Loading Levels......Page 546
Drawing the Rooms......Page 547
Improving on Basic Techniques......Page 549
Introducing the Viewing Frustum......Page 550
Planes and Clipping......Page 551
The cFrustum Class......Page 554
Developing an Advanced 3-D Engine......Page 560
Introducing the NodeTree Engine......Page 561
Creating the cNodeTree Class......Page 565
Using cNodeTree......Page 583
Adding 3-D Objects to the World......Page 584
Computing the Bounding Sphere......Page 585
Collision Detection with Meshes......Page 586
Colliding with the World......Page 587
When Meshes Collide......Page 592
Mouse Clicks and Meshes......Page 594
Using Sky Boxes......Page 596
Creating a Sky Box Class......Page 597
Wrapping Up 3-D Graphics......Page 603
Mixing 2-D and 3- D Graphics Engines......Page 604
Mixing the Two Dimensions......Page 605
Drawing Tiles in 3-D......Page 606
Moving in the 3-D World......Page 610
Adding 3-D Objects to a 2- D World......Page 611
Dealing with 2-D Backdrops......Page 613
Dealing with the Scene Mesh......Page 615
Rendering the Scene......Page 617
Wrapping Up Mixed Engines......Page 619
Implementing Scripts......Page 622
Understanding Scripts......Page 623
Lib Script System......Page 625
Mad Lib Script System......Page 627
Working with the MLS Editor......Page 646
Executing Mad Lib Scripts......Page 649
Wrapping Up Scripting......Page 654
Defining and Using Objects......Page 656
Defining Objects for Your Game......Page 657
Using Form in Objects......Page 658
Defining the Functions of Objects......Page 659
Adding Function to Objects......Page 663
Constructing the MIL......Page 669
Using the MIL Editor......Page 671
Accessing Items from the MIL......Page 673
Managing Items with Inventory Control Systems......Page 674
Developing a Map ICS......Page 676
Developing a Character ICS......Page 687
Wrapping Up Objects and Inventory......Page 693
Controlling Players and Characters......Page 696
Players, Characters, and Monsters, Oh My!......Page 697
Defining Characters in Your Game......Page 698
The Player Character......Page 706
Non- Player Characters......Page 708
Monster Characters......Page 709
Character Graphics......Page 710
Navigating Characters......Page 711
Controlling Player Characters......Page 712
Controlling Non- Player Characters......Page 716
Conversation among Characters......Page 726
The Talking Dummy......Page 727
and Other Text......Page 728
The Script Class......Page 738
Creating a Derived Script Class......Page 739
Using Items......Page 744
Using Magic......Page 745
Working with Magic and Spells......Page 746
Spell Graphics......Page 747
The Function of Spells......Page 748
The Master Spell List......Page 752
Creating a Spell Controller......Page 758
Using the Spell Controller......Page 764
Combat and Characters......Page 765
Using Combat Rules for Attacking......Page 766
Spells in Combat......Page 770
Intelligence in Combat......Page 771
Building the Master Character List......Page 772
The MCL Editor......Page 776
Meshes with sCharacterMeshList......Page 778
Moving with sRoutePoint......Page 779
with sCharacter......Page 780
The cCharacterController Class......Page 785
Using cCharacterController......Page 798
Demonstrating Characters with the Chars Demo......Page 800
Wrapping Up Characters......Page 802
Working with Maps and Levels......Page 804
Character Map Lists......Page 805
Script Placement......Page 808
Sphere Triggers......Page 809
Box Triggers......Page 810
Triggering a Trigger......Page 811
Creating a Trigger Class......Page 812
Using Triggers......Page 830
Blocking the Path with Barriers......Page 831
and cBarrier: : SetAnim......Page 835
cBarrier: : Render......Page 837
Adding Barriers with cBarrier......Page 838
Using the Barrier Class......Page 839
Using Auto Maps......Page 840
Big Map, Small Map......Page 841
Loading and Displaying Auto Maps......Page 845
Creating the Auto Map Class......Page 846
Using cAutomap......Page 858
Wrapping Up Maps and Levels......Page 859
Creating Combat Sequences......Page 862
Designing External Combat Sequences......Page 863
The Technical Side......Page 865
Developing the Combat Sequence......Page 867
Global Data......Page 869
cApp: : Init......Page 870
cApp: : Shutdown......Page 874
cApp: : Frame......Page 875
cApp: : GetCharacterAt......Page 881
Wrapping Up Combat Sequences......Page 884
Getting Online with Multiplayer Gaming......Page 886
Maddening Multiplayer Mayhem......Page 887
Multiplayer Game Design......Page 888
The Network Demo......Page 890
Creating a Multiplayer Game Architecture......Page 892
The Client and the Server......Page 893
the Server......Page 897
Looking at Clients......Page 899
Working with Game Servers......Page 900
Storing Player Information......Page 902
Handling Messages......Page 903
Updating Players......Page 924
Calculating Latency......Page 927
The Hard Part Is Over!......Page 928
Handling Player Data......Page 929
The Network Component......Page 932
Message Handling......Page 934
Updating the Local Player......Page 939
Updating All Players......Page 945
Wrapping Up Multiplayer Gaming......Page 948
Part 5 - The Finishing Touches......Page 950
Putting Together a Full Game......Page 952
Writing the Game s Story......Page 953
Designing the Levels......Page 955
Defining the Characters......Page 959
Creating the Items and Spells......Page 962
Developing the Scripts......Page 965
Defining the Controls......Page 968
Laying Out the Flow......Page 970
Programming the Sample Game......Page 971
Structuring the Application......Page 974
Using State- Based Processing......Page 981
Dealing with Maps......Page 988
Controlling Characters......Page 992
Handling Bartering......Page 1000
Playing Sounds and Music......Page 1001
Rendering the Scene......Page 1003
Processing Scripts......Page 1004
Wrapping Up Creating Games......Page 1008
Marketing and Publishing Your Game......Page 1010
Submitting Your Game......Page 1011
Performing Marketing Analysis......Page 1012
Determining Schedules......Page 1013
Including a Game Demo......Page 1014
Communicating with Companies......Page 1015
Negotiating Your Contract......Page 1016
Considering Which Publishers to Contact......Page 1017
Do- It- Yourself Publishing......Page 1019
Approach......Page 1020
Your Product......Page 1021
Wrapping Up Marketing and Publishing......Page 1022
Looking Back......Page 1023
What s Next?......Page 1024
Part 6 - Appendixes......Page 1026
Setting Up DirectX 8.0 and Configuring the Compiler......Page 1028
Setting Up DirectX 8.0......Page 1029
Installing DirectX 8.0......Page 1030
Installing DirectMusic Producer......Page 1031
Setting Up the Compiler......Page 1032
Linking to Libraries......Page 1033
Setting Default char Behavior......Page 1035
Multithreaded Libraries......Page 1036
Getting Help on the Web......Page 1038
Flipcode......Page 1039
Steve Jackson Games......Page 1040
www. excite. com/ games/ role_ playing......Page 1041
Recommended Reading......Page 1042
Dungeons & Dragons 3rd Edition Player s Handbook......Page 1043
Multiplayer Game Programming......Page 1044
The Zen of Direct3D Game Programming......Page 1045
Glossary......Page 1046
What's on the CD......Page 1060
DirectX 8.0 SDK......Page 1061
MilkShape 3D 1.56 Demo......Page 1062
trueSpace5 Demo......Page 1063
A......Page 1064
B health/ mana points, updating, 837......Page 1065
C......Page 1066
D......Page 1071
F......Page 1075
G GM/ GS set, 337......Page 1077
H......Page 1078
J......Page 1079
N......Page 1085
O......Page 1086
R......Page 1088
S......Page 1089
T......Page 1092
U......Page 1096
W......Page 1097