This is just going to be a short introduction to creating your own text adventure. I’ll start getting into code in another post. They’ll assume only the most basic of programming knowledge, more on that later.
So why am I writing this? Surprisingly I found it more difficult than I would have expected to find resources for absolute beginners writing their own parser for a text adventure so I thought this would be a good place to put one that might be useful to others! Your google skills may be better than mine however, feel free to share resources in the comments.
In case you just wandered across this post and are wondering, a text adventure, or Interactive Fiction (IF) as they have become to be known are a very specific type of game, defined by the input method. To play an IF, in a way, you become part of the story as you type in your actions and see how the world reacts, and of course the world itself is (almost) always pure text. It can range from the simple ‘go north’, to the more prosaic ‘drop everything except the sword’ and so on. They do this using a text parser, which takes the player input a breaks it down into a series of commands the computer can hopefully understand and act on. Arguably the most famous of these is Zork which can be played online for free. My own attempt can be found on my itch.io page and is free to download if you want to see what I came up with.
There are plenty of engines to be found that can help you create a text adventure without having to worry over much about learning to program such as Quest and Inform7, which will also handle parsing all the players text. You can focus on world and story building and not worry about the nuts and bolts. Inform7 in particular is a very refined system. If that’s what you want to do go forth and create! The rest of this article and it’s follow ups may not be for you.
Programming your own parser is, while a challenge, definitely something the fledgling programmer can do. The process can of course be as frustrating and rewarding as writing any kind of code but there’s something that little bit extra satisfying about getting a computer to understand and act on your words. And like anything you can make it as complex or simple as you want. It’s also a great way to push your skills and learn new concepts.
You’ll need to know a few very basic concepts to follow these tutorials. You’ll need conditionals, so that’s your if, else if and else statements right there. You’ll need loops, for and while, and of course a few variables, integers and booleans will suffice. While not necessary it’s good to know about enums, arrays, structs, functions and includes but don’t sweat it, I’ll get into them if you don’t.
What I’ll hopefully teaching you is how to create your own map, how to populate that map with object and how to deal with player input using nouns and verbs. We’ll start small and simple and work out way up to the finished product.
If you start with this, I strongly advise you keep at it until you have something you can play. The feeling of finishing your own game is worth all the work twice over.