Dim ROOM$(NUM_ROOMS),DESC$(NUM_ROOMS),NORTH(NUM_ROOMS),SOUTH(NUM_ROOMS),WEST(NUM_ROOMS),EAST(NUM_ROOMS)
Dim UP(NUM_ROOMS),DWN(NUM_ROOMS)
Dim OBJ$(NUM_OBJS),OBJDESC$(NUM_OBJS),OBJDESC2$(NUM_OBJS),OBJLOC(NUM_OBJS),OBJVAR(NUM_OBJS)
Dim CARRIED(NUM_OBJS),DESCRIBE(NUM_OBJS),INOBJ(NUM_OBJS)
' describe variable describes an object.
' 1 - Object not shown after a look command and cannot be got
' 2 - Object not shown but is examinable
' 4 - Object breaks after dropping
' 8 - Object is openable and is open
' 16 - Object is openable and closed
' 32 - Object is Locked (closed)
' 64 - Object is in another object (inobj var)
'128 - Object is on another object
'256 - Object is under " "
'512 - Object is behind " "
SETSCENE:
Print "This is the beginings of an adventure that I never finished. What there is of it is quite playable, and the source code should give you some ideas on writing adventures of your own."
Print "Type quit to end."
Print
Print "Marty has been thrown back in time to 194O when a time travel experiment went wrong.";
Print " Unfortunately, pieces of the time machine have been scattered over a wide area. It is your";
Print " job to direct Marty around the town and find all the pieces of the time machine before it ";
Print "is too late!"
Print
'
GTDAT:
' Description of Variables
'Room$= name of room, desc$=description of room,north etc= room arived at
'if moved in that dir. obj$=objectname,objloc =location of obj
Data "White classroom","The classroom is large and airy with white painted walls. The floor is very highly polished and quite slippery. There is a large blackboard at the far side of the room, and a large table in the middle.",0,2,4,0,0,0
Data "Narrow corridor","The corridor is very dark and has wooden coatpegs along one wall and stairs at the end.",0,3,0,1,0,5
Data "Laboratory","The laboratory is large and painted green. Along the far wall are glass cabinets containing a variety of pickled creatures.",0,0,0,2,0,0
Data "Staff room","The room is empty except for a table and three chairs it smells revolting inhere!",0,5,0,0,0,0
Data "School entrance hall","The Entrance Hall is very large with doors leading east and west. To the North is a large wooden starcase leading upwards.",0,6,8,4,2,0
Data "Blue classroom","This classroom is small but tidy everything is very clean. There is a large window to the north, covering the whole wall.",0,0,0,5,0,0
Data "The street","I am on a narrow cobbled street leading east. There is a dead end to the west.",0,8,0,0,0,0
Data "The street","I am on a narrow cobbled street running east - west. It seems to get wider to the east, opening out into a main road.",5,9,0,7,0,0
Data "The street","I am on a cobbled street which widens out to the east. To the west, the street gets much narrower and darker.",0,14,0,8,0,0
Data "Great Hall","The Great Hall is a huge room with a shiny wooden floor. Various portraits are hung around the walls and the room is lit by a central chandelier.",0,11,12,0,0,0
Data "Mayor's office","The Mayor's office is a small dimly lit room with a single north facing window. There is a large desk towards the back of the room, with a comfy looking chair. There is a picture hanging above the desk.",0,0,13,10,0,0
Data "Inside Town Hall","This building has obviously suffered some bomb damage as there is a small pile of rubble in the middle of the floor. Looking up, daylight can be seen through a hole in the ceiling.",10,13,14,0,0,0
Data "Committee room","This is where the town council meets. It is a large room, with a polished wooden table surrounded by twenty chairs. I can see the Mayor's office through the door to the north.",11,0,0,12,0,0
Data "The road","I am on the road outside the Town Hall. To the west, the road narrows into acobbled street.",12,15,0,9,0,0
Data "The road","I am in the road, but cannot go any further as it is blocked. The only way is back the way I came.",0,0,0,14,0,0
Data "Key","It looks and feels like solid gold. Could be quite valuable, Doc.","Gold Key",1,2,257,4
Data "Watch","It is a ninetees digital watch with a built in address book. The face was cracked in the accident, but it seems to be working Ok.","Digital Watch",0,1,1,0
Data "Table","The table is very large and made of solid wood. It looks far too heavy to move","Large Table",1,3,3,0
Data "Bible","The bible is very old and dusty. It appears to have several pages missing.","Dusty Bible",1,2,1,0
Data "Jar","The jar seems to contain a pickled bat!.","Pickling Jar",3,2,1,0
Data "Book","It is a dull brown excercise book with some sums scribbled inside.","Excercise book",4,1,1,0
Data "Marble","The marble is plain white and quite boring.","White marble",8,1,5,0
Data "Cupboard","It looks as though it could be quite valuable, possibly an antique.","Antique Cupboard",3,3,33,0
Data "Coin","It looks really valuable. It has a date on it... 35O BC. Wow! that's Old!","Gold Coin",3,1,64,8
Data "Picture","It is a rather large portrait of Winston Churchill. It seems to take up mostof the wall.","Portarit",11,5,7,0
Data "Chandelier","It is a large crystal chandelier with twenty candle shaped bulbs.","Crystal Chandelier",10,6,7,0
Data "Windows","They are large with painted wooden frames.","Large Windows",1,3,7,0
Data "Stairs","It is a large solid wood staircase. It appears to have woodworm.","Staircase",5,3,7,0
Data "Pegs","They are just like any other wooden coatpegs.","Coatpegs",2,5,7,0
Data "Blackboard","It has the three times table written on it, but nothing else.","Board",1,5,7,0
Data "Desk","It's just like any other office desk.","Office desk",11,3,7,0
Data "Chair","It's a comfy black leather armchair. It seems to be attached to the floor.","Armchair",11,4,7,0
Data "Pictures","I don't recognise any of the faces.","Portarits",10,5,7,0
Data "Phase Lock Module","It's a component from the time machine.","Module",3,1,64,8
Data "Flux Capacitor","This is the main component from the time machine.","Capacitor",10,1,1,0
Data "Time Projection Unit (TPU)","This is the time control we need.","TPU",7,1,1,0
'Carrying watch
CARRIED(2)=1
DISPLAY:
MD=5 : Gosub ACTION
Gosub EX
'
' Get User Input
'
PARSER:
MD=0 : Rem move direction variable
Pen 0 : Print ">";
Pen 4
'
Line Input "";I$ : Pen 1
I$=Upper$(I$)
If I$="SAVE GAME" Then Gosub SVGAME : Goto PARSER
If I$="LOAD GAME" Then Gosub LDGAME : Goto PARSER
While Right$(I$,1)="."
I$=Left$(I$,Len(I$)-1)
Wend
'
While Instr(I$," THE ")>0
X=Instr(I$," THE ")
If X>0
I$=Left$(I$,X-1)+Right$(I$,Len(I$)-X-3)
End If
Wend
'
While Instr(I$," TO ")>0
X=Instr(I$," TO ")
If X>0
I$=Left$(I$,X-1)+Right$(I$,Len(I$)-X-2)
End If
Wend
If Right$(I$,2)="IT" Then NOUN$=OBJ$(LASTOBJ) : Goto CHKDIRS
If Right$(I$,4)="THEM" Then NOUN$=OBJ$(LASTOBJ) : Goto CHKDIRS
NOUN$=Right$(I$,Len(I$)-Instr(I$," "))
If Left$(NOUN$,3)="AT " Then NOUN$=Right$(NOUN$,Len(NOUN$)-3)
If Left$(NOUN$,3)="IN " Then NOUN$=Right$(NOUN$,Len(NOUN$)-3)
For X=1 To NUM_OBJS
If NOUN$=Upper$(OBJ$(X)) Then MD2=X : LASTOBJ=X
If NOUN$=Upper$(OBJDESC2$(X)) Then MD2=X : LASTOBJ=X
Next X
CHKDIRS:
If Left$(I$,3)="GO " Then I$=Right$(I$,Len(I$)-3)
If Left$(I$,4)="RUN " Then I$=Right$(I$,Len(I$)-4)
If Left$(I$,5)="WALK " Then I$=Right$(I$,Len(I$)-5)
If I$="RUN" Then Print "Which way?" : Print : Goto PARSER
If I$="WALK" Then Print "Which way?" : Print : Goto PARSER
If I$="N" Then MD=1
If I$="E" Then MD=2
If I$="S" Then MD=3
If I$="W" Then MD=4
If I$="U" Then MD=11
If I$="D" Then MD=12
If I$="NORTH" Then MD=1
If I$="EAST" Then MD=2
If I$="SOUTH" Then MD=3
If I$="WEST" Then MD=4
If Left$(I$,2)="UP" Then MD=11
If Left$(I$,4)="DOWN" Then MD=12
If I$="LOOK" Then MD=5
If I$="L" Then MD=5
If I$="EXITS" Then MD=6
If Left$(I$,1)="X" Then MD=6
If I$="I" Then MD=7
If I$="INV" Then MD=7
If I$="INVENTORY" Then MD=7
If Left$(I$,4)="EXAM" Then MD=8
If Left$(I$,7)="LOOK AT" Then MD=8
If Left$(I$,7)="LOOK IN" Then MD=8
If Left$(I$,4)="L AT" Then MD=8
If Left$(I$,4)="TAKE" Then MD=9
If Left$(I$,7)="PICK UP" Then MD=9
If Left$(I$,3)="GET" Then MD=9
If Left$(I$,4)="DROP" Then MD=10
If Left$(I$,4)="OPEN" Then MD=13
If Left$(I$,5)="UNLOC" Then MD=14
If Left$(I$,4)="LOCK" Then MD=15
If Left$(I$,4)="CLOS" Then MD=16
If Left$(I$,4)="SHUT" Then MD=16
If Left$(I$,4)="MOVE" Then MD=17
If Left$(I$,4)="PUSH" Then MD=17
If Left$(I$,4)="PULL" Then MD=17
If Left$(I$,4)="QUIT" Then Stop
Gosub ACTION
Goto PARSER
'
'action
ACTION:
ACTED=0
If MD=5
Print "I am in the ";ROOM$(LOCATION);"."
Print DESC$(LOCATION)
For X=1 To NUM_OBJS
If OBJLOC(X)=LOCATION
If DESCRIBE(X) and 1
If(DESCRIBE(X) and 2)=0
If INOBJ(X)=0 and(DESCRIBE(X) and 64)=0
Print " I can see a ";Lower$(OBJ$(X));"."
End If
End If
End If
End If
Next
ACTED=1 :
End If
If MD=1 and NORTH(LOCATION)>0 Then LOCATION=NORTH(LOCATION) : Print ROOM$(LOCATION) : ACTED=1
If MD=2 and EAST(LOCATION)>0 Then LOCATION=EAST(LOCATION) : Print ROOM$(LOCATION) : ACTED=1
If MD=3 and SOUTH(LOCATION)>0 Then LOCATION=SOUTH(LOCATION) : Print ROOM$(LOCATION) : ACTED=1
If MD=4 and WEST(LOCATION)>0 Then LOCATION=WEST(LOCATION) : Print ROOM$(LOCATION) : ACTED=1
If MD=11 and UP(LOCATION)>0 Then LOCATION=UP(LOCATION) : Print ROOM$(LOCATION) : ACTED=1
If MD=12 and DWN(LOCATION)>0 Then LOCATION=DWN(LOCATION) : Print ROOM$(LOCATION) : ACTED=1
'
If MD=1 and NORTH(LOCATION)=0 and ACTED=0 Then Print "I can't go that way." : ACTED=1
If MD=2 and EAST(LOCATION)=0 and ACTED=0 Then Print "I can't go that way." : ACTED=1
If MD=3 and SOUTH(LOCATION)=0 and ACTED=0 Then Print "I can't go that way." : ACTED=1
If MD=4 and WEST(LOCATION)=0 and ACTED=0 Then Print "I can't go that way." : ACTED=1
If MD=11 and UP(LOCATION)=0 and ACTED=0 Then Print "I can't go up." : ACTED=1
If MD=12 and DWN(LOCATION)=0 and ACTED=0 Then Print "I can't go down." : ACTED=1
If MD=6 Then Gosub EX : ACTED=1
If MD=7 Then Gosub INVENTORY : ACTED=1
If MD=8 Then Gosub EXAM : ACTED=1
If MD=9 Then Gosub PICKUP : ACTED=1
If MD=10 Then Gosub DROP : ACTED=1
If MD=13 Then Gosub OPEN : ACTED=1
If MD=14 Then Gosub UNLOCK : ACTED=1
If MD=15 Then Gosub LOCK : ACTED=1
If MD=16 Then Gosub CLOS : ACTED=1
If MD=17 Then Gosub PUSH : ACTED=1
If ACTED=0 Then Print "Sorry, I don't understand."
Print
Return
EX:
Print "Possible exits : ";
If NORTH(LOCATION) Then Print " North ";
If SOUTH(LOCATION) Then Print " South ";
If EAST(LOCATION) Then Print " East ";
If WEST(LOCATION) Then Print " West ";
If UP(LOCATION) Then Print " Up ";
If DWN(LOCATION) Then Print " Down ";
Print : Print
Return
'
INVENTORY:
Print "I am carrying :-"
XX=0
For X=1 To NUM_OBJS
XX=XX+CARRIED(X)
If X>18 Then Pen 5 Else Pen 1
If CARRIED(X)>0 Then Print OBJDESC2$(X)
Next
If XX=0 Then Print " Nothing."
Return
'
EXAM:
'
'check to see if noun is a room first.
For X=1 To NUM_ROOMS
If Upper$(ROOM$(X))=NOUN$ and LOCATION=X
Print DESC$(X)
Return
End If
Next X
If(DESCRIBE(MD2) and 1)=0
Print "Sorry, I can't see that here."
Return
End If
If OBJLOC(MD2)<>LOCATION
If CARRIED(MD2)=0
Print "Sorry, can't see it here!"
Return
End If
End If
Print OBJDESC$(MD2)
If(DESCRIBE(MD2) and 32)=32
Print "It is closed and locked."
End If
If(DESCRIBE(MD2) and 16)=16
Print "It is closed."
End If
If(DESCRIBE(MD2) and 8)
Print "It is open."
For X=1 To NUM_OBJS
If INOBJ(X)=MD2 and(DESCRIBE(X) and 64)=64
Print "It has a ";OBJ$(X);" in it."
End If
Next X
End If
Return
'
PICKUP:
If OBJLOC(MD2)<>LOCATION
Print "Sorry, I can't see that here!"
Return
End If
If(DESCRIBE(MD2) and 1)=0
Print "Sorry, I can't see that here, Doc!"
Return
End If
If OBJVAR(MD2)=3
Print "I can't move it, it's too heavy."
Return
End If
If OBJVAR(MD2)=4
Print "But it's bolted to the floor."
Return
End If
If OBJVAR(MD2)=5
Print "But it's stuck to the wall."
Return
End If
If OBJVAR(MD2)=6
Print "But it's too high. I can't reach it."
Return
End If
XX=0 : For X=1 To NUM_OBJS
XX=XX+CARRIED(X)
Next X
If XX>10
Print "Sorry, I can't carry any more at the moment."
Return
End If
CARRIED(MD2)=OBJVAR(MD2)
Print "OK, I've got the ";OBJ$(MD2);"."
OBJLOC(MD2)=0
For X=1 To NUM_OBJS
If INOBJ(X)=MD2
If(DESCRIBE(X) and 256)=256
Print "There was something underneath it."
DESCRIBE(X)=DESCRIBE(X)-256
INOBJ(X)=0
End If
If(DESCRIBE(X) and 512)=512
Print "There was something behind it."
DESCRIBE(X)=DESCRIBE(X)-512
INOBJ(X)=0
End If
End If
Next
Return
'
DROP:
If CARRIED(MD2)>0
If DESCRIBE(MD2) and 2
Print "I can't drop that!"
Return
End If
If DESCRIBE(MD2) and 4
Print "The ";OBJ$(MD2);" hits the ground and breaks."