Writing BASIC Adventure Programs for the TRS‑80
|Title:||Writing BASIC Adventure Programs for the TRS‑80|
|Publisher:||TAB Books Inc.|
|Number of pages:||222|
|Buy it from Amazon|
Adventure games were some of the earliest games written for computers and they were incredibly popular at the beginning of the microcomputer revolution. Despite this popularity, there were only a handful of books that showed how adventure games worked in detail or how to write one. In my opinion, the best book of this type was Writing BASIC Adventure Programs for the TRS-80 by Frank DaCosta. Published in 1982 by TAB Books, Writing BASIC Adventure Programs for the TRS‑80 describes two different types of adventure games, with full listings that the reader could type in to the computer. (Both programs were also available through the mail from the author for $19.95 on either disk or tape.)
DaCosta devotes the main part of the book (the first ten chapters) to Basements and Beasties, a classic text adventure in the mold of William Crowther’s original Adventure. After describing how an adventure game works in general, DaCosta lays out the framework needed for a text adventure.
Much of the book promotes good programming practices and shows how to write a well-structured program within the limits of a BASIC interpreter. He also describes techniques specific to a text adventure, such as creating maps, as well as potential pitfalls, particularly in item and room descriptions. Especially interesting is chapter 10 “Improving the program,” which details some optimizations that greatly speed up the program. In particular, one shortens the maximum word search time from four seconds to milliseconds.
DaCosta presents the Basements and Beasties program listing in a clever way. Although each chapter adds new code to the program, it always remains runnable (though incomplete) after each chapter. This means that anyone could read the book and follow along by typing in the code for each chapter. This way, each new concept is added as it is presented. The downside of this approach is that most versions of Basements and Beasties available today are incomplete, as if someone stopped typing before finishing all the chapters. For example, no copy I know of implements any of the optimizations given in chapter 10.
The last three chapters of the book describe the design of a “graphic adventure”: a Rogue-like adventure named Mazies and Crazies. This game is somewhat less interesting from a modern point of view, although it is still interesting as a historical snapshot.
Although Writing BASIC Adventure Programs for the TRS‑80 focuses on programming adventure games, it teaches lessons that apply to programming in general. I think the best lesson is that good programming practices are essential for writing complex programs. At the end of the book, DaCosta summarized three key concepts he viewed as important:
- Structure your programming:
“No program of any real complexity can avoid the debug-correction cycle, and an unstructured program can be difficult to correct.”
- Consider your options: “In an input-oriented program like Basements and Beasties, someone is bound to phrase a command or try something in a way you hadn’t predicted – possibly with disastrous results to your program flow!”
- Optimize your code: “Find ways to simplify your statements and speed up program execution.”
These concepts remain important to good programming today.
For those interested in seeing more about Basements and Beasties, the always entertaining Gaming After 40 weblog has a nice walkthrough.