Game Development Reference
so. I'm going to assume you know the basics of good writing, and even that you
understand what it means to write an interactive story, one with branching dialogue
and player choices that matter and make a difference to the outcome. Let's say you
have a story idea you're keen on, and you're thinking about writing it as an IF game,
because then you can do it yourself and not worry about pitching it to a studio. But
you've never written programming code in your life, and so you're freaked out. Well,
please don't be.
First of all, you're not starting from nothing. There are several programming
languages and tools specifically designed for writing IF. I'll talk about choosing a
language later, but for now we'll talk about them in general. The task boils down to:
when the player types X, the game should print Y. It is all about printing the right
bit of text at the right time, and these languages are designed to make it as intuitive
and clean as possible for an IF author to do just this.
19.3 The World Model and the Library
Any modern IF language comes with two pieces of underlying technology already set
up for you: the world model and the library.
The world model is the game space that the player character (PC) of an IF game
wanders around in. It defines a set of spatial relationships between rooms, objects,
and characters, which you don't have to worry about programming. A room connects
to another room, allowing travel in between. An object that has a flat surface can have
things put on top of it, and the PC can possibly climb up on top of it, stand on it, or
sit on it. A container can have things put into it or taken out of it. Things that can
hide other objects are searchable.
This now overlaps with the library, which defines the interactive tissue that holds
the world together and allows things to happen. It defines archetypal classes of items:
chairs, doors, keys, non-player characters (NPCs). All of the basic command verbs
are defined, allowing objects to be examined, pushed, pulled, turned, switched on or
off, climbed, dropped, taken, boarded, worn, thrown, or eaten. The library allows
for NPCs to be spoken to, attacked, kissed, given items, and ordered around. The
PC can jump, sing, pray, lie down, stand up, swim, and sleep.
Now, what I mean by the world model and the library allowing for these things—
that objects can have these properties and attributes and that these actions can be
taken—is that generic versions of them exist that produce default, generic responses.
It is trivial to create, compile, and run an IF game that has a couple of rooms, each
with an object or an NPC in it, and a generic PC who will be able to enter all of the
above commands to interact with the world. Without your having to write anything
special, the game will automatically provide responses to all of that input. Of course,
you can already see where I'm going: none of the responses are going to be special.
You need to write them.
So, to put a chair in your game, you write some definition code that says you
want an instance of a chair-type object. You specify where you want it, then you add