Lets make a Commodore 64 Text Adventure Game!

A simple tutorial by John Christian Lonningdal

Part 5 - Room specific commands and game logic

Ok, next up is the logic for the actual gameplay, this is room specific commands like movement from one room to another as well as interaction with objects and NPCs. The actual puzzles are coded here. Lets take a look at the code first:

No secrets here, just a simple ON..GOTO again that executes the command tests based on which room you are in. This includes all room navigation which all set OK = 2 meaning that a room change has happened and a LOOK coomand will be executed immediately after. Other than that there is some logic here and there to allow the buyer to EXAMINE objects, BUY SWORD, PRAY, PUSH BOULDER and KILL CHAOS. The final command having no less than 4 outcomes based on whether you are a believer of the power of the mask and have the sword or not and will jump to a printout of the climax based on this (shown in next part).

It is clear again that this code is not very optimal again. First all room navigation requires a lot of code and is very inefficient as the game gets larger. We will definitely have to do something about this. Some operations really should be more generic as well, like EXAMINE which is possibly something you can do at all times, even on objects you are carrying with you. Other than that, actual game logic can be a bit tricky to generalise, and many games tend to add "scripts" to solve this, but in our case we will most probably stick to pure Basic for this, but make it easier to "configure" the game for where more advanced logic is required. More about this when we look at a fun little Basic trick using some POKEs.

Part 6 - Game endings
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.