| *E was an esquire, with pride on his brow;*
| *F was a farmer, and followed the plough.*
-Each of the three games in this guide is created step by step; you'll get
+.. only:: html
+
+ .. image:: /images/picE.png
+ :align: left
+
+.. raw:: latex
+
+ \dropcap{e}
+
+ach of the three games in this guide is created step by step; you'll get
most benefit (especially to begin with) if you take an active part, typing
in the source code on your computer. Our first game, described in this
chapter and the two which follow, tells this sentimental little story:
#. In that folder, use your text editor to create this source file
``Heidi.inf``:
- .. code-block:: inform
+ .. code-block:: inform6
!% -SD
!============================================================================
Ensure the file is named ``Heidi.inf``, rather than ``Heidi.txt`` or
``Heidi.inf.txt``.
- Remember that, throughout this guide, we place the "TYPE" symbol
+ Remember that, throughout this guide, we place the "``TYPE``" symbol
alongside pieces of code that we recommend you to type into your own
game files as you read through the examples (which, conversely, means
- that you don't need to type the unmarked pieces of code). You'll learn
- Inform more quickly by trying it for yourself, rather than just taking
- our word for how things work.
+ that you *don't* need to type the unmarked pieces of code). You'll
+ learn Inform more quickly by trying it for yourself, rather than just
+ taking our word for how things work.
.. todo::
By the way, the compiler *doesn't* give special treatment to exclamation
marks in quoted text: ``!`` within quotes "..." is treated as a normal
character. On this line, the first ``!`` is part of the sequence (or
- string) of characters to be displayed:
+ **string**) of characters to be displayed:
- .. code-block:: inform
+ .. code-block:: inform6
print "Hello world!"; ! <- is the start of this comment
space (except when the spaces are part of a character string). So, these
two rules tell us that we *could* have typed the source file like this:
- .. code-block:: inform
+ .. code-block:: inform6
Constant Story "Heidi";
Constant Headline
* Every game needs the three lines which ``Include`` the standard library
files -- that is, they merge those files' contents into your source file:
- .. code-block:: inform
+ .. code-block:: inform6
Include "Parser";
Include "VerbLib";
* Every game needs to define an ``Initialise`` routine (note the British
spelling):
- .. code-block:: inform
+ .. code-block:: inform6
[ Initialise; ];
that's why we were able to take three lines to define the ``Headline``
constant
- .. code-block:: inform
+ .. code-block:: inform6
Constant Headline
"^A simple Inform example
this example none of them has four walls. So let's use Inform to define
those rooms. Here's a first attempt:
-.. code-block:: inform
+.. code-block:: inform6
Object "In front of a cottage"
with description
routes, we also need to explicitly add them to the room definitions in a
form that the game itself can make sense of. Like this:
-.. code-block:: inform
+.. code-block:: inform6
Object before_cottage "In front of a cottage"
with description
with the sketch map until you're comfortable that you understand how to
create simple rooms and define the connections between them.
-.. code-block:: inform
+.. code-block:: inform6
!============================================================================
Constant Story "Heidi";
bird and its nest are Inform objects. We'll start their definitions like
this:
-.. code-block:: inform
+.. code-block:: inform6
Object bird "baby bird"
with description "Too young to fly, the nestling tweets helplessly.",
appropriate to her, with a good chance of it being understood. We add a
line to each definition:
-.. code-block:: inform
+.. code-block:: inform6
Object bird "baby bird"
with description "Too young to fly, the nestling tweets helplessly.",
name 'bird^s' 'nest' 'twigs' 'moss',
has ;
-The ``name`` introduces a list in single quotes '...'. We call each of
-those quoted things a **dictionary word**, and we do mean "word", not
-"phrase" (``'baby'``\ ``'bird'`` rather than ``'baby bird'``); you can't
-uses spaces, commas or periods in dictionary words, though there's a space
-*between* each one, and the whole list ends with a comma. The idea is that
-the interpreter decides which object a player is talking about by matching
-what she types against the full set of all dictionary words. If the player
-mentions BIRD, or BABY BIRD, or NESTLING, it's the ``baby bird`` that she
-means; if she mentions NEST, BIRD'S NEST or MOSS, it's the ``bird's nest``.
-And if she types NEST BABY or BIRD TWIGS, the interpreter will politely say
-that it doesn't understand what on earth she's talking about.
+The ``name`` introduces a list in single quotes '...'. We call each of
+those quoted things a **dictionary word**, and we do mean "word", not
+"phrase" (``'baby'``\ ``'bird'`` rather than ``'baby bird'``); you can't
+uses spaces, commas or periods *in* dictionary words, though there's a
+space *between* each one, and the whole list ends with a comma. The
+idea is that the interpreter decides which object a player is talking
+about by matching what she types against the full set of all dictionary
+words. If the player mentions BIRD, or BABY BIRD, or NESTLING, it's the
+``baby bird`` that she means; if she mentions NEST, BIRD'S NEST or MOSS,
+it's the ``bird's nest``. And if she types NEST BABY or BIRD TWIGS, the
+interpreter will politely say that it doesn't understand what on earth
+she's talking about.
.. note::
Furthermore, we label it as ``open``; this prevents the interpreter from
asking us to open it before putting in the bird.
-.. code-block:: inform
+.. code-block:: inform6
Object nest "bird's nest"
with description "The nest is carefully woven of twigs and moss.",
them. Let's say that the bird is found in the forest, while the nest is in
the clearing. This is how we set this up:
-.. code-block:: inform
+.. code-block:: inform6
Object bird "baby bird" forest
with description "Too young to fly, the nestling tweets helplessly.",
they're found. This means adding the bird just after the forest, and the
nest just after the clearing. Here's the middle piece of the source file:
-.. code-block:: inform
+.. code-block:: inform6
!============================================================================
! The game objects
The description of the clearing mentions a tall sycamore tree, up which the
player character supposedly "climbs". We'd better define it:
-.. code-block:: inform
+.. code-block:: inform6
Object tree "tall sycamore tree" clearing
with description
from being picked up by the player character. One final object: the branch
at the top of the tree. Again, not many surprises in this definition:
-.. code-block:: inform
+.. code-block:: inform6
Object branch "wide firm bough" top_of_tree
with description "It's flat enough to support a small object.",
name 'wide' 'firm' 'flat' 'bough' 'branch',
has static supporter;
-The only new things are those two labels. ``static`` is similar to
-``scenery``: it prevents the branch from being picked up by the player
-character, but *doesn't* suppress mention of it when describing the
-setting. And ``supporter`` is rather like the ``container`` that we used
-for the nest, except that this time the player character can put other
-objects *onto* the branch. (In passing, we'll mention that an object can't
-normally be both a ``container`` and a ``supporter``.) And so here are our
-objects again:
+The only new things are those two labels. ``static`` is similar to
+``scenery``: it prevents the branch from being picked up by the player
+character, but *doesn't* suppress mention of it when describing the
+setting. And ``supporter`` is rather like the ``container`` that we
+used for the nest, except that this time the player character can put
+other objects *onto* the branch. (In passing, we'll mention that an
+object can't normally be both a ``container`` *and* a ``supporter``.)
+And so here are our objects again:
-.. code-block:: inform
+.. code-block:: inform6
!============================================================================
! The game objects
put the bird into the nest first. One easy way to enforce this is by
adding a line near the top of the file:
-.. code-block:: inform
+.. code-block:: inform6
!============================================================================
Constant Story "Heidi";
place it on the branch; when that happens, the game should be over. This
is one way of making it happen:
-.. code-block:: inform
+.. code-block:: inform6
Object branch "wide firm bough" top_of_tree
with description "It's flat enough to support a small object.",