X-Git-Url: https://jxself.org/git/?p=ibg.git;a=blobdiff_plain;f=chapters%2F06.rst;h=495b8d4b973a4b183b4f03e53809c770ef6055a7;hp=f706c8660e56c5ce93176921e1aab572fa49d6c9;hb=95b5702817b987123d71d432f81eeb0c7101b59c;hpb=a94081289bc21041a8daac44d8c8b6714a831281 diff --git a/chapters/06.rst b/chapters/06.rst index f706c86..495b8d4 100644 --- a/chapters/06.rst +++ b/chapters/06.rst @@ -6,19 +6,15 @@ .. epigraph:: - | *K was King William, once governed the land;* - | *L was a lady, who had a white hand.* + | |CENTER| *K was King William, once governed the land;* + | |CENTER| *L was a lady, who had a white hand.* .. only:: html .. image:: /images/picK.png :align: left -.. raw:: latex - - \dropcap{k} - -eeping up the momentum, this chapter (and the three which follow) works +|K|\eeping up the momentum, this chapter (and the three which follow) works steadily through the design of the "William Tell" game that we encountered right at the start of this guide. Many of the principles are the same as the ones we explained when designing Heidi and her forest, so we'll not @@ -204,7 +200,7 @@ The game won't compile in this state, because it contains references to objects which we haven't yet defined. In any case, we don't intend to build up the game in layers as we did last time, but rather to talk about it in logically related chunks. To see (and if you wish, to type) the -complete source, go to "William Tell" story on page 219. +complete source, go to :doc:`/appendices/c`. Object classes ============== @@ -267,14 +263,14 @@ We've done four things: #. We don't need to explicitly include the ``light`` attribute each time; every ``Room`` object has it automatically. -A **class** is a family of closely related objects, all of which behave in -the same way. Any properties defined for the class, and any attributes +A :term:`class` is a family of closely related objects, all of which behave +in the same way. Any properties defined for the class, and any attributes defined for the class, are automatically given to objects which you specify as belonging to that class; this process of acquisition just by being a -member of a class is called **inheritance**. In our example, we've defined -a ``Room`` class with a ``light`` attribute, and then we've specified four -objects each of which is a member of that class, and each of which gets -given a ``light`` attribute as a result of that membership. +member of a class is called :term:`inheritance`. In our example, we've +defined a ``Room`` class with a ``light`` attribute, and then we've +specified four objects each of which is a member of that class, and each of +which gets given a ``light`` attribute as a result of that membership. Why have we gone to this trouble? Three main reasons: @@ -339,7 +335,10 @@ You'll notice that, if an object has no block of attributes, the semicolon which terminates its definition simply moves to the end of its last property. -.. rubric:: A class for props +.. _props-class: + +A class for props +----------------- We use the ``Room`` class in "William Tell", and a few other classes besides. Here's a ``Prop`` class (that's "Prop" in the sense of a @@ -408,7 +407,8 @@ The interesting things that this statement demonstrates are: nest", ``(a) nest`` would display "a bird's nest", ``(A) nest`` would display "A bird's nest" and ``(name) nest`` would display just "bird's nest". This use of a word in parentheses, telling the interpreter how to - display the following object's internal ID, is called a **print rule**. + display the following object's internal ID, is called a :term:`print + rule`. * There's a library variable ``self`` which always contains the internal ID of the current object, and is really convenient when using a ``Class``. @@ -433,7 +433,8 @@ object like Heidi's ``tree`` and ``cottage``, is to support EXAMINE for increased realism, while clearly hinting to players that trying other verbs would be a waste of time. -.. rubric:: A class for furniture +A class for furniture +--------------------- The last class for now -- we'll talk about the ``Arrow`` and ``NPC`` classes in the next chapter -- is for furniture-like objects. If you label @@ -474,6 +475,6 @@ probably reuse them in your next game. Now that most of our class definitions are in place, we can get on with defining some real rooms and objects. First, though, if you're typing in the "William Tell" game as you read through the guide, you'd probably like -to check that what you've entered so far is correct; "Compile-as-you-go" on -page 233 explains how to compile the game in its current -- incomplete -- -state. +to check that what you've entered so far is correct; +:ref:`compile-as-you-go` explains how to compile the game in its current -- +incomplete -- state.