From 7a7b15f69f40dbe90b71990ab45a59ed60846df1 Mon Sep 17 00:00:00 2001 From: David Griffith Date: Wed, 13 Apr 2016 02:50:23 -0700 Subject: [PATCH] Added Appendix C. --- appendices/c.rst | 186 ++++++++++++++++++++++++++++++++++++++++++++++ examples/Tell.txt | 170 ++++++++++++++++++++++++++++++++++++++++++ images/picW.png | Bin 0 -> 3095 bytes 3 files changed, 356 insertions(+) create mode 100644 appendices/c.rst create mode 100644 examples/Tell.txt create mode 100644 images/picW.png diff --git a/appendices/c.rst b/appendices/c.rst new file mode 100644 index 0000000..c82f0b3 --- /dev/null +++ b/appendices/c.rst @@ -0,0 +1,186 @@ +.. raw:: latex + + \newpage + +====================================== + Appendix C -- "William Tell" story +====================================== + + +.. only:: html + + .. image:: /images/picW.png + :align: left + +.. raw:: latex + + \dropcap{w} + +illiam Tell, our second game, is also very straightforward. See "William +Tell: a tale is born" on page 69, "William Tell: the early years" on +page 79, "William Tell: in his prime" on page 91 and "William Tell: the +end is nigh" on page 103. + +Transcript of play +================== + +.. literalinclude:: /examples/Tell.txt + :language: transcript + +Game source code +================ + +.. literalinclude:: /examples/Tell.inf + :language: inform6 + +Compile-as-you-go +================= + +Your understanding of how the "William Tell" game works will be +considerably enhanced if you type in the code for yourself as you read +through the guide. However, it takes us four chapters to describe the +game, which isn't complete and playable until the end of Chapter 9. Even +if you make no mistakes in your typing, the game won't compile without +errors before that point, because of references in earlier chapters to +objects which aren't presented until later chapters (for example, +Chapter 6 mentions the ``bow`` and ``quiver`` objects, but we don't +define them until Chapter 7). This is a bit of a nuisance, because as a +general rule we advise you to compile frequently -- more or less after +every change you make to a game -- in order to detect syntax and +spelling mistakes as soon as possible. + +Fortunately, there's a fairly easy way round the difficulty, though it +involves a little bit of cheating. The trick is temporarily to add +minimal definitions -- often called "stubs" -- of the objects whose full +definitions have yet to be provided. + +For example, if you try to compile the game in the state that it's +reached by the end of Chapter 6, you’ll get this:: + + Tell.inf(16): Warning: Class "Room" declared but not used + Tell.inf(19): Warning: Class "Prop" declared but not used + Tell.inf(27): Warning: Class "Furniture" declared but not used + Tell.inf(44): Error: No such constant as "street" + Tell.inf(46): Error: No such constant as "bow" + Tell.inf(47): Error: No such constant as "quiver" + Compiled with 3 errors and 3 warnings + +However, by adding these lines to the end of your game file:: + + ! =============================================================== + ! TEMPORARY DEFINITIONS NEEDED TO COMPILE AT THE END OF CHAPTER 6 + + Room street; + Object bow; + Object quiver; + +a compilation should now give only this:: + + Tell.inf(19): Warning: Class "Prop" declared but not used + Tell.inf(27): Warning: Class "Furniture" declared but not used + Compiled with 2 warnings + +That's a lot better. It's not worth worrying about those warnings, since +it's easy to understand where they come from; anyway, they'll go away +shortly. More important, there are no errors, which means that you've +probably not made any major typing mistakes. It also means that the +compiler has created a story file, so you can try "playing" the game. If +you do, though, you'll get this:: + + William Tell + A simple Inform example + by Roger Firth and Sonja Kesserich. + Release 3 / Serial number 040804 / Inform v6.30 Library 6/11 SD + + (street) + ** Library error 11 (27,0) ** + ** The room "(street)" has no "description" property ** + > + +Whoops! We've fallen foul of Inform's rule saying that every room must +have a ``description`` property, to be displayed by the interpreter when +you enter that room. Our ``street`` stub hasn't got a ``description``, +so although the game compiles successfully, it still causes an error to +be reported at run-time. + +The best way round this is to extend the definition of our ``Room`` +class, thus:: + + Class Room + with description "UNDER CONSTRUCTION", + has light; + +By doing this, we ensure that *every* room has a description of some +form; normally we'd override this default value with something +meaningful -- "The narrow street runs north towards the town square..." +and so on -- by including a ``description`` property in the object's +definition. However, in a stub object used only for testing, a default +description is sufficient (and less trouble):: + + William Tell + A simple Inform example + by Roger Firth and Sonja Kesserich. + Release 3 / Serial number 040804 / Inform v6.30 Library 6/11 SD + + (street) + UNDER CONSTRUCTION + + >INVENTORY + You are carrying: + a (quiver) (being worn) + a (bow) + + >EXAMINE QUIVER + You can't see any such thing. + + > + +You'll notice a couple of interesting points. Because we didn't supply +external names with our ``street`` , ``bow`` and ``quiver`` stubs, the +compiler has provided some for us -- ``(street)`` , ``(bow)`` and +``(quiver)`` -- simply by adding parentheses around the internal IDs +which we used. And, because our ``bow`` and ``quiver`` stubs have no +``name`` properties, we can't actually refer to those objects when +playing the game. Neither of these points would be acceptable in a +finished game, but for testing purposes at this early stage -- they'll +do. + +So far, we've seen how the addition of three temporary object +definitions enables us to compile the incomplete game, in its state at +the end of Chapter 6. But once we reach the end of Chapter 7, things +have moved on, and we now need a different set of stub objects. For a +test compilation at this point, remove the previous set of stubs, and +instead add these -- ``south_square`` and ``apple`` objects, and a dummy +action handler to satisfy the ``Talk`` action in Helga’s life property:: + + ! =============================================================== + ! TEMPORARY DEFINITIONS NEEDED TO COMPILE AT THE END OF CHAPTER 7 + + Room south_square; + Object apple; + + [ TalkSub; ]; + +Similarly, at the end of Chapter 8, replace the previous stubs by these +if you wish to check that the game compiles:: + + ! =============================================================== + ! TEMPORARY DEFINITIONS NEEDED TO COMPILE AT THE END OF CHAPTER 8 + Room marketplace; + Object apple; + NPC son; + + [ TalkSub; ]; + [ FireAtSub; ]; + [ SaluteSub; ]; + +Finally, by the end of Chapter 9 the game is complete, so you can delete +the stubs altogether. + +Used with care, this technique of creating a few minimal stub objects +can be convenient -- it enables you to "sketch" a portion of your game +in outline form, and to compile and test the game in that state, without +needing to create complete object definitions. However, you've got very +little interaction with your stubs, so don't create too many of them. +And of course, never forget to flesh out the stubs into full definitions +as soon as you can. diff --git a/examples/Tell.txt b/examples/Tell.txt new file mode 100644 index 0000000..c89048b --- /dev/null +++ b/examples/Tell.txt @@ -0,0 +1,170 @@ +The place: Altdorf, in the Swiss canton of Uri. The year is 1307, at +which time Switzerland is under rule by the Emperor Albert of Habsburg. +His local governor -- the vogt -- is the bullying Hermann Gessler, who +has placed his hat atop a wooden pole in the centre of the town square; +everybody who passes through the square must bow to this hated symbol of +imperial might. + +You have come from your cottage high in the mountains, accompanied by +your younger son, to purchase provisions. You are a proud and +independent man, a hunter and guide, renowned both for your skill as an +archer and, perhaps unwisely (for his soldiers are everywhere), for +failing to hide your dislike of the vogt. + +It's market-day: the town is packed with people from the surrounding +villages and settlements. + +William Tell +A simple Inform example +by Roger Firth and Sonja Kesserich. +Release 3 / Serial number 040804 / Inform v6.30 Library 6/11 SD + +A street in Altdorf +The narrow street runs north towards the town square. Local folk are +pouring into the town through the gate to the south, shouting greetings, +offering produce for sale, exchanging news, enquiring with exaggerated +disbelief about the prices of the goods displayed by merchants whose +stalls make progress even more difficult. + +"Stay close to me, son," you say, "or you'll get lost among all these +people." + +>EXAMINE YOUR SON +A quiet, blond lad of eight summers, he's fast learning the ways of +mountain folk. + +>GO NORTH + +Further along the street +People are still pushing and shoving their way from the southern gate +towards the town square, just a little further north. You recognise the +owner of a fruit and vegetable stall. + +Helga pauses from sorting potatoes to give you a cheery wave. + +"Hello, Wilhelm, it's a fine day for trade! Is this young Walter? My, +how he's grown. Here's an apple for him -- tell him to mind that scabby +part, but the rest's good enough. How's Frau Tell? Give her my best +wishes." + +>INVENTORY +You are carrying: + an apple + a quiver (being worn) + three arrows + a bow + +>TALK TO HELGA +You warmly thank Helga for the apple. + +[Your score has just gone up by one point.] + +>GIVE THE APPLE TO WALTER +"Thank you, Papa." + +[Your score has just gone up by one point.] + +>NORTH + +South side of the square +The narrow street to the south has opened onto the town square, and +resumes at the far side of this cobbled meeting place. To continue along +the street towards your destination -- Johansson's tannery -- you must +walk north across the square, in the middle of which you see Gessler's +hat set on that loathsome pole. If you go on, there's no way you can +avoid passing it. Imperial soldiers jostle rudely through the throng, +pushing, kicking and swearing loudly. + +>EXAMINE THE SOLDIERS +They're uncouth, violent men, not from around here. + +>EXAMINE HAT +You're too far away at the moment. + +>N +Middle of the square +There is less of a crush in the middle of the square; most people prefer +to keep as far away as possible from the pole which towers here, topped +with that absurd ceremonial hat. A group of soldiers stands nearby, +watching everyone who passes. + +>X HAT +The pole, the trunk of a small pine some few inches in diameter, stands +about nine or ten feet high. Set carefully on top is Gessler's ludicrous +black and red leather hat, with a widely curving brim and a cluster of +dyed goose feathers. + +>N +A soldier bars your way. + +"Oi, you, lofty; forgot yer manners, didn't you? How's about a nice +salute for the vogt's hat?" + + +>N + +"I know you, Tell, yer a troublemaker, ain't you? Well, we don't want no +bovver here, so just be a good boy and salute the friggin' hat. Do it +now: I ain't gonna ask you again..." + +>N + +"OK, Herr Tell, now you're in real trouble. I asked you nice, but you +was too proud and too stupid. I think it's time that the vogt had a +little word with you." + +And with that the soldiers seize you and Walter and, while the sergeant +hurries off to fetch Gessler, the rest drag you roughly towards the old +lime tree growing in the marketplace. + + +Marketplace near the square + +Altdorf's marketplace, close by the town square, has been hastily +cleared of stalls. A troop of soldiers has pushed back the crowd to +leave a clear space in front of the lime tree, which has been growing +here for as long as anybody can remember. Usually it provides shade for +the old men of the town, who gather below to gossip, watch the girls, +and play cards. Today, though, it stands alone... apart, that is, from +Walter, who has been lashed to the trunk. About forty yards away, you +are restrained by two of the vogt's men. + +Gessler is watching from a safe distance, a sneer on his face. + +"It appears that you need to be taught a lesson, fool. Nobody shall pass +through the square without paying homage to His Imperial Highness +Albert; nobody, hear me? I could have you beheaded for treason, but I'm +going to be lenient. If you should be so foolish again, you can expect +no mercy, but this time, I'll let you go free... just as soon as you +demonstrate your archery skills by hitting this apple from where you +stand. That shouldn't prove too difficult; here, sergeant, catch. +Balance it on the little bastard's head." + + +>X GESSLER +Short, stout but with a thin, mean face, Gessler relishes the power he +holds over the local community. + +>X WALTER +He stares at you, trying to appear brave and remain still. His arms are +pulled back and tied behind the trunk, and the apple nestles amid his +blond hair. + +>X APPLE +At this distance you can barely see it. + +>SHOOT THE APPLE +Slowly and steadily, you place an arrow in the bow, draw back the +string, and take aim with more care than ever in your life. Holding your +breath, unblinking, fearful, you release the arrow. It flies across the +square towards your son, and drives the apple against the trunk of the +tree. The crowd erupts with joy; Gessler looks distinctly disappointed. + +*** You have won *** + +In that game you scored 3 out of a possible 3, in 17 turns. + +Would you like to RESTART, RESTORE a saved game or QUIT? +> QUIT + + diff --git a/images/picW.png b/images/picW.png new file mode 100644 index 0000000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