Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

5. Building a Text Game Engine > Describing It All

Describing It All

Now we’ll tie all of these description functions into one easy command called look. Because this will be the actual command players can enter to look around them in the game, look will need to know a player’s current location. So, we need a variable to track the player’s current position. Let’s call it *location*:

(defparameter *location* 'living-room)

Because the *location* value is initialized to the living-room symbol, which occurs at the very start of the game, players will find themselves in the living room of the wizard’s house. At this point, we can write a look function to describe everything we need by having it call all of our descriptor functions:

(defun look ()
  (append (describe-location *location* *nodes*)
          (describe-paths *location* *edges*)
          (describe-objects *location* *objects* *object-locations*)))

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint