Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL



With fingers blistered and eyes bloodshot, all your hard work is about to pay off. After one hundred hours of playing the newest computer-based role-playing game, you’ve managed to reach the end. All that stands between you and victory is a very large, very angry dragon. Not to worry though—you have a couple of tricks up your sleeve to show this sucker who’s boss. After a final climatic battle, your mission is over—the game is defeated.

Your quest was long and difficult, but when all is said and done, it was a very enjoyable quest. The story was compelling, the graphics eye-popping, the sound and music superb. Sitting back, you might be wondering how you could create such a masterpiece. Something with a snappy title, a great story, and that neat-o battle engine from that newest game with the kick-butt graphics engine. “Yes,” you say, “I can do that!”


Before working with the code or exam ples in this book,you need to properly install DirectX 8.0 and set up your compiler accordingly. You can find the DirectX 8.0 installation program on this book’s CD-ROM,or you can download the program from Microsoft’s Web site at Please turn to Appendix A,“Installing DirectX and Configuring the Compiler,” for the details.

Programming Role Playing Games with DirectX is your ticket to bringing your ideas to life. Within these pages, I have crammed enough information about general programming and role-playing game topics to give you the help you need to create your own game. In this book, you find out how to create cool graphics and combat engines, handle players in your game, use scripts and items, and make your game multiplayer-capable.

What This Book Is About

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. To see exactly what components I’m talking about, scan ahead to the section “How This Book Is Organized.”

Within these pages and on the accompanying CD-ROM, you’ll find example programs that were created using the information in each chapter. I constructed these example programs so that you can easily transfer the various general and RPG-specific game components into your projects. For the specifics on running the example programs, check out Appendix E, “What’s on the CD.” In fact, I recommend checking out the demo programs before reading the book. That way, you’ll know what to expect in the book.

Who Should Read This Book

If you want to put extra oomph in your game, this book is for you. You will find helpful hints and ideas and all the information you need to embark on your career as an RPG programmer.

I wrote this book for beginning- to intermediate-level RPG programmers. The information is clear and to the point, and regardless of your programming experience and skills, you will find that this book is a valuable tome.

I wrote this book on the assumption that you have a working knowledge of C. A good deal of the code is in C++, but I lead you through it in such a way that you will be able to fully comprehend the information.

So, if you’re interested in programming a role-playing game or just want help on a specific gaming component, this is the book for you.

How This Book Is Organized

The book is split into the following six parts, each one dealing with a different set of topics:

  • Part One , “An Introduction to Role-Playing Games,” describes role-playing games and their fundamental operation.

  • Part Two , “ Role-Playing Game Design,” discusses game design topics and provides help for writing your game’s story. This part begins with fundamental concepts and continues with RPG-specific design issues from a programmer’s point of view.

  • Part Three , “Programming Basics,” is where things really heat up. This hefty part offers you the basics on using C++, getting a Windows application up and running, and utilizing DirectX in your game programming projects.

  • Part Four , “Role-Playing Game Programming,” contains all the RPG-specific gaming code that I could pack into those pages. Topics include creating 2-D and 3-D graphics engines, controlling your game’s characters, using scripting and inventory, and multiplayer gaming.

  • Part Five , “The Finishing Touches,” helps you wrap up your project. In this part, you find out how I created a complete game using the information in this book. In addition, you learn how to promote, market, and publish your game.

  • Part Six , “Appendixes,” starts by showing you how to install DirectX and configure your compiler to use DirectX. You will find a list of recommended books and Web sites. Part Six ends with an appendix describing how to use this book’s CD-ROM.

What’s on the CD

Appendix E, “What’s on the CD,” contains a list of the programs on this book’s CD-ROM; however, I can’t resist giving you a glimpse of what you’ll find there. First and foremost are Microsoft’s DirectX 8.0 software developer’s kit and the complete source code to every demo program in this book.

DirectX is the leader among game development libraries, and it’s the library I use in this book. Before reading this book, take a moment to install DirectX on your system. Appendix A tells you exactly how to install DirectX and prepare your compiler to use DirectX.

In addition to DirectX and the source code, the CD-ROM contains a plethora of useful programs. “Which programs,” you ask? How about Calgiari’s trueSpace4 trial edition and Curious Lab’s Poser 4 demo! That’s right; you get to test drive the newest, most powerful modeling programs out there! But there’s more. The complete DirectX 8.0 SDK, chUmbaLum’s MilkShape 3D, a Paint Shop Pro demo, and much more—all packed into that little round disc!

Conventions Used in This Book

This book has the following special features, called icons, that point you to important or interesting information.


Notesprovide additional helpful or interesting information.



Cautionstell you how to avoid problems.



Tipsoften suggest techniques and short cuts that make programming easier.

What You Need to Begin

Before beginning, you need to install the Microsoft DirectX 8.0 Software Developer’s Kit, which is on this book’s CD-ROM (or you can download it from Microsoft at Appendix A provides the steps for installing DirectX.

You also need a C++ compiler; I recommend Microsoft’s Visual C/C++ compiler. Even though you can compile the code and examples in this book with almost any C++ compiler, the DirectX-specific code was targeted for Visual C/C++ version 6.0 or higher.

Beyond those two items, you just need dedication and motivation! Although creating any game is a daunting task, with this book, you will have all the knowledge you need to do just that—and, remember, players are waiting for your masterpiece!

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint