Title
Site Home Page Site Home Page Building a Text Adventure game Refrigerate After Opening cartoon series Captin Corner graphic novel About This Site
Text Adventures

 

UPDATE

The Text Adventure Game is on hold for a bit. Partly because in a few chapters I'll be getting to AI techniques, and I need to do a fair amount of research on those. Partly because I'm skipping ahead many chapters and then skipping back.

Mostly because... um, hah. Yeah, this thing sucks. Well, not "sucks" but there's a ton of things on my "wish I'd done differently" list and before I go on I want to address those. Creating a template list and tree is high up on those. I've already gutted the book and I'm in the process of re-assembling it. I'm much happier with it now.

Of course, I've said that before. :)

I'll get you some update, promise, but might not be until November. Then I'll dump a whole new experience at ya.

 

Text Adventure games used to be a staple of computer geeks everywhere. Back in the 1970s and 1980s, when computer memory and processing power were minimal, they were best ways to have some kind of large strategy game. Rather than plunk the user down in an immersive 3D environment, text adventure games would print a paragraph describing what the player would see. The player would then type in what to do, either through a menu system or by entering some keywords. There were no graphics; instead the computer would rely on the player’s imagination.

But time moves on and games began adding layers of graphics previously unimaginable: first with simple 2D environments, like Pac Man or Asteroids; then with side-scrollers like Mario or Sonic the Hedgehog; and finally with 3D environments from Doom all the way up to Halo. Heck, phones these days carry way more processing power than early computers did.

There are tons of books on how to create 2D, 3D and side-scroller games, but very few modern books on text adventure games. What I found was mostly written in Basic. Not Visual Basic, mind you, but Basic... 10 GOTO 20 and all that.

And why would anyone want to read a book on text adventure games when one could read up on the latest 3D environment? I think there is a market for it, because text adventure games are an excellent introduction to computer programming. Or, in my case, an excellent re-introduction.

Way back in at the start of the millennium, in those halcyon days before the Dot Com Crash, 9/11 and the Great Recession, I headed back to school for a computer programming degree. I’d loved working on computers in middle and high school, even building a text adventure game in old-school Basic. For some reason, however, I never pursued that course. Stupid, stupid, stupid... So I gave myself a second chance.

One summer during my second chance I wanted to synthesize my notes and build another text adventure game, not so much in Basic this time. Unfortunately some life stuff happened and I had to leave my second chance a semester early, setting aside programming for over five years. I got out of practice with coding by a lot. What better way to re-learn programming than finally creating that text adventure game I’d been dreaming of? Live your dreams!

Except then I had to get all fancy and decide I’d blog it, and the blog quickly became a book. I’m over 150 pages into a Word document on the subject and that’s under halfway done. On the plus side, I now have a tutorial on computer programming, by building a text-based adventure game using C++. Thought I’d share.

The first handful of chapters covers the basics of programming. It’s for any reader who’s never programmed before. The first chapter is about the basics of programming. The second starts building a temporary map for the game, and covers a bit about databases and how we’ll save information about the map. The third chapter covers data structures and the fourth gives a very brief description on object oriented programming. Then we actually sit down and do some real coding in the fifth, sixth and seventh chapters. We use object oriented methodology to create a list and tree data structure. In the eighth chapter, we take our map database, our tree and list classes and apply them to a rudimentary text adventure game.

After that we’ll take a brief break and discuss how to develop a program, the early stages before sitting down and coding. Future chapters will re-do the menu system, add items, characters and events to the game, and try to get some form of artificial intelligence into the characters. Finally we’ll create a “real” game instead of the temporary tiny map we’ve been using.

A few caveats: I am out of practice with coding and I have no real workplace experience. Everything I’m about to cover is based on old, semi-intelligible school notes and what I’ve read in books. Take that as you may. Also, this is very much a first draft. There are a lot of things I’ll re-do in subsequent versions. For example, next version I’ll make the list generic instead of practically throwing it away later on.

If you spot something that looks weird or doesn’t work, or you’re a real coder that’s horrified by what you’re reading, feel free to leave critiques, corrections and comments. Please keep it friendly, I’m a fragile, fragile man. ;)

I: Hello World
In which we very quickly cover some basics of programming, and how that applies to building a game.
1.1 Hello World
1.2 Using a Compiler
1.3 Two Roads Diverged in a Wood
1.4 Variables
1.5 Binary
1.6 Naming Variables
1.7 If, or the Selection Structure
1.8 Logic: Or, Xor, And, Not and Mod
1.9 Loops, or Iterative Structures
1.10 Functions
1.11 Comments
1.12 The Three Room Program
1.13 Passing Information & Issues of Scope
1.14 Stack Overflow and Recursion

II: The Map
In which we build a rudimentary map for our game, along with a quick lesson on databases.
2.1 Creating the Environment
2.2 A Quick Note on Graph Theory
2.3 Databases
2.4 Database Design
2.5 Our Map Database
2.6 Describing the Environment
2.7 What's Next?

III: Data Structures
In which we cover data structures, ways to put our map information into our game program.
3.1 Intro to Data Structures
3.2 Arrays
3.3 Strings
3.4 The Struct
3.5 Pointers
3.6 Lists and Trees
3.7 Object Oriented Programming

IV: Classes
In which we cover the basics of object oriented programming.
4.1 Objects?
4.2 OOP Terminology
4.3 Encapsulation
4.4 Abstraction
4.5 Inheritance
4.6 A Simple Sample Class
4.7 A Simple Sample Inheritance Example
4.8 Public, Private and Protexted Inheritance
4.9 Passing Values to a Class
4.10 Join Us Next Week

V: The List Class
In which we build a list class to use in our game.
5.1 Creating a List Class
5.2 Starting Up and the Node Class
5.3 Starting and Ending the List Class
5.4 Adding Nodes
5.5 Printing the List
5.6 Removing Nodes

VI: Sorting, Algorithms and Big O Notation
In which we take a brief break to cover sorting algorithms, as well as code time and optimization.
6.1 An Overview of Sorting
6.2 The Bubble Sort
6.3 Big O Notation
6.4 The Quick Sort
6.5 The "Best Sort"

VII: Binary Search Trees
In which we build a tree class.
7.1 Our Tree Class
7.2 Encapsulation and Abstraction
7.3 Constructor and Destructor
7.4 Adding Nodes and Recursion Redux
7.5 Traversing and Printing the Tree
7.6 Information: Tree Size and Depth
7.7 Testing the Tree
7.8 Printing the Tree as a Tree
7.9 Removing Nodes
7.10 Destroying the Tree
7.11 Balancing the Tree
7.12 Balancing the Tree: Post Mortem

VIII: The Game Begins
In which we apply all we’ve learned so far to create a rudimentary game.
8.1 Our Game
8.2 File Handling
8.3 The New Classes
8.4 The Standard Template Library
8.5 Setting Up the Game
8.6 Debug Mode
8.7 Play
8.8 By Your Command
8.9 Shutdown

IX: Development and Debugging
In which we take an intermission and discuss the development cycle of programming, documentation, and finally the debugging process.
9.1 The Development Process
9.2 The Waterfall Method
9.3 Spiral
9.4 The Scrum
9.5 Cowboy Computing
9.6 Documentation
9.7 Diagramming
9.8 Tools
9.9 Debugging