KEYS
from Home Computing Weekly, 26th July 1983

Trapped! Find the keys before the ghost gets a taste for you.


Here's a maze game with a difference - instead of gobbling fruit you have to
find keys to unlock the door. But beware of the ghost, says William Mitchell
who wrote the program for 16K or 48K Spectrum.

You are trapped in a maze with a door at the top left-hand corner of the
screen. However, to open the door and escape you must first get the five keys
to it which are scattered around the maze. But a ghost patrols the maze and
if it sees you it will sound the alarm and you will be captured and eaten.

The random movement of the ghost may be of particular interest to readers
wishing to write "Pacman"-style games. It is in lines 300 to 330.


How it works
  90-260   print maze
 261-266   position keys
 270-280   define variables
 300-330   random movement of ghost
 331-470   main program loop
2000-3001  check to see if ghost has seen man
4000-4020  set up graphics (A - man; B - ghost)
4030-7000  instructions and restart

Variables
The important variables are:
y,z   position of ghost
d     direction
a,b   position of man
e,f   used to set up position of man

Hints on conversion
The program could be easily converted to the ZX81 if BEEPs, colour commands
(INK, PAPER, BORDER) and user-defined graphics were not used (lines 4000-4020).
Also, the SCREEN$ command would have to be replaced by the PEEK (PEEK 16398+
256*PEEK 16399) command.
