How to Make Text Based Games
Text-based games, also known as "interactive fiction" (I.F.) games, have come a long way since the days of Zork and Hitchhiker's Guide to the Galaxy. Though no longer commercially viable, an energetic fan community exists around their continued development. There are three major, custom I.F. development platforms, all of them free: TADS, HUGO and Inform, with Inform being the most popular, and the one used in this tutorial.
Instructions
-
-
1
Choose an Inform version. There are two major versions of Inform available: 6 and 7. The difference between them is dramatic. Version 6 offers a more traditional, object-oriented programming syntax, whereas version 7 attempts something much more ambitious: game development in plain, 'natural language' English (see References 1). Each has their strengths and weaknesses, but this tutorial will assume that you use version 7.
-
2
Define the title and author of the text-based game. This is actually very simple in Inform 7. Write the following in the Inform 7 window:
"A Game" by "Amber Rollins"
The story headline is "A Tutorial By Amber Rollins". -
-
3
Create some rooms to explore. The syntax for creating a room is very simple: The name of the room, followed by "is a room." And next the description of the room that should be shown to the player. Add the following to the Inform game:
The Ling Room is a room. "A small living room with a roaring fireplace, a computer, and an office chair."
The Kitchen is a room. "A cozy kitchen."Game play will begin in the Living Room, since that is the first room defined in the story.
-
4
Connect the rooms. You've defined two rooms, but you need to connect them, so the computer knows their relation to each other on the map. Add this to your game:
The Living Room is east of the Kitchen.
-
5
Create objects. It's good practice in an I.F. game that every noun mentioned in your game that refers to a tangible object should be defined in your game. The code so far has mentioned a fireplace, a computer and an office chair. You'll need to define all of those in your game file, because nothing is more jarring to the experience than saying "examine computer" and being told that the player doesn't see the computer (even though it was described to them as in the room).
A computer is in the Living Room. The description is "A shiny new MacBook Pro." Understand "MacBook Pro" as the computer. Understand "macbook" as the computer.
A fireplace is in the Living Room. The description is "A roaring fire is going."
An office chair is in the Living Room. The office chair is a chair. The description is "It looks comfortable." Understand "chair" as the office chair.A few things have happened here. The compiler was told to "understand" chair to mean office chair, and this is a way to define synonyms for the game. You've also defined the office chair as being a "chair", because chair is an object already understood by the Inform language as an object that can be sat in.
You now have a basic, functioning text based game.
-
1
Tips & Warnings
Use 'Inform English', not 'Real English'. Inform 7 attempts to let you program in plain English, but there are significant limits to that. There is still a defined syntax for the language that must be followed. For example, in the above example, the phrase "Understand "chair" as the office chair" is used. This could also be expressed "Chair is a synonym for office chair." Even though this is valid English, the compiler will not understand.