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 Objects at a Specific Location

Describing Objects at a Specific Location

To create the final piece of code to help us visualize our game world, we need to describe the objects on the floor at a given location, which a player can pick up and use.

Listing Visible Objects

To do so, we first create a list of the objects:

> (defparameter *objects* '(whiskey bucket frog chain))
*OBJECTS*
image with no caption

We can also create a second variable, *object-locations*, to track the location of each object in the form of an alist:

(defparameter *object-locations* '((whiskey living-room)
                                   (bucket living-room)
                                   (chain garden)
                                   (frog garden)))

Next, we write a function that lists the objects visible from a given location:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

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

  

Start a Free 10-Day Trial


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