Lets make a Commodore 64 Text Adventure Game!

A simple tutorial by John Christian Lonningdal

Part 3 - Some command implementations

So the game has 3 simple commands that work on every room at this point, QUIT, INV and LOOK. Here is the implementation of these (which were all called from the previous code snippet) :

The first is the LOOK command which will call 3 subroutines, one that displays the current room description, another that displays the directions you can go and the last which shows the objects you see here. The LOOK command is also called automatically in the start and whenever you move from one room to another.

The QUIT command doesnt need much explanation so we will jump to the INV command which will list the objects you are carrying. Again the implementation is very crude, relying on the state variables we talked about earlier. Since our short adventure game is... well short... you will at any particular point maximum carry one object. So we will need to modify the output to support more than one at a later point, and we definitely need to optimize the code so that the object text is reused in both room listing and inventory listing as well as for the commands themselves.

Part 4 - Room, Object and Direction descriptions
Back to index
 
 
All images and text are Copyrighted by John Christian Lønningdal 2007-2015 unless indicated.
Until Microsoft bothers to implement the standards this site will look best on Firefox, Opera or Chrome.