Making Text Adventure Games in Ruby
Making a Text Adventure Game in Ruby
Text adventure games were a very popular game genre on minicomputers and microcomputers from the 1970's through the 1990's. This article series will take you through each step of making a text adventure game in Ruby.
One Tree to Rule Them All
Some problems seem difficult, there are just too many things to consider and it's going to become a mess. However, if you analyze it, there's often a single data structure that will make the whole thing easier.
We've been organizing our game data in a tree, but a tree is kind of hard to visualize. Single objects and arrays you can simply puts to the terminal, but trees are a bit more difficult. Two methods are presented, one that prints the tree to the terminal and another that generates an image.
Finding and Moving Nodes
While text adventure games have many interactions, almost everything aside from the scripting involves finding a node and moving it somewhere else.
Now that we have most of the support code for the game finished, it's time to implement the player. The player where everything happens, the API for this whole thing, if you will.
A text adventure game without scripting, using only the built-in game mechanics is a game that gets boring quickly. This is especially true, since most challenges in text adventure games are puzzle-based.
Saving, Loading and Cleaning Up
Saving and loading a game state is often a difficult process. You must save the entire state of the game and load it exactly as it was, or something will go amiss. However, this is trivial for our text adventure game.