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

6. Interacting with the World: Reading a... > Adding a Custom Interface to Our Gam...

Adding a Custom Interface to Our Game Engine

So far, we’ve been using the Lisp REPL to enter our game commands. It’s amazing how well this works for prototyping our game. But now that you’ve gained an understanding of the basic Common Lisp input and output commands, we can begin to put in place our own custom text game interface, which will be better suited for interacting with the player.

Setting Up a Custom REPL

Creating your own REPL in Lisp is almost laughably easy. Here’s a simple custom REPL for our game, which lets us call the look command in exactly the same way as the standard REPL did:

> (defun game-repl ()
     (loop (print (eval (read)))))
GAME-REPL
> (game-repl)
(look)

(YOU ARE IN THE LIVING-ROOM. A WIZARD IS SNORING LOUDLY ON THE COUCH. THERE IS
 A DOOR GOING WEST FROM HERE. THERE IS A LADDER GOING UPSTAIRS FROM HERE. YOU
 SEE A WHISKEY ON THE FLOOR.)

  

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