This is the main routine in my new game called package boy, can you find the exit (without typing exit)
Randomize Timer
'this is the map structure
dim key(6,4)
for a = 1 to 6
for b = 1 to 4
read key(a,b)
next b
next a
data 2,0,0,0 'room 1 or sidewalk
data 3,1,5,0 'room 2 or Lounge
data 0,2,4,0 'room 3 or hallway
data 0,0,0,3 'room 4 or men's room
data 6,0,0,2 'room 5 or game room
data 0,5,0,0 'room 6 or package room
dim as string room(6)
dim as integer z
'assigning room names
room(1) = "Side-walk in front of Bruno's."
room(2) = "Lounge area."
room(3) = "Hallway in front of the bathrooms."
room(4) = "Men's room."
room(5) = "Game room."
room(6) = "Package room."
rn = 1 'rn means room number
screen 18
#include "name.bas"
main:
'this is the moving around part of the interaction
cls
locate 9
print player_name; ","
print : print "You are in the "; room(rn)
if key(rn,1) <> 0 then print "There is a door to the north"
if key(rn,2) <> 0 then print "There is a door to the south"
if key(rn,3) <> 0 then print "There is a door to the east"
if key(rn,4) <> 0 then print "There is a door to the west"
print "(type 'exit' to quit the game)"
input "Which direction would you like to go? (n, s, e, w) ", d$
if d$ <> "n" then
if d$ <> "s" then
if d$ <> "e" then
if d$ <> "w" then
if d$ <> "exit" then
gosub bad_input
else
goto wrong_way
end if
end if
end if
end if
end if
wrong_way:
if d$ = "n" then
if key(rn,1) = 0 then
cls
locate 9
print "You can't go that way"
sleep 1000
else
rn = key(rn,1)
end if
end if
if d$ = "s" then
if key(rn,2) = 0 then
cls
locate 9
print "You can't go that way"
sleep 1000
else
rn = key(rn,2)
end if
end if
if d$ = "e" then
if key(rn,3) = 0 then
cls
locate 9
print "You can't go that way"
sleep 1000
else
rn = key(rn,3)
end if
end if
if d$ = "w" then
if key(rn,4) = 0 then
cls
locate 9
print "You can't go that way"
sleep 1000
else
rn = key(rn,4)
end if
end if
if d$ = "exit" then end
if rn > 1 and rn < 6 then goto main
if rn = 1 then gosub room1
if rn = 6 then gosub room6
goto main
bad_input:
cls
locate 9
print "error: not a valid entry"
print "please enter n, s, e, w, or exit"
print "press any key to continue"
while inkey$ = "": wend
return
room1:
if z = 0 then
goto main
else
cls
print "Congratulations, you figured it out"
while inkey$ = "": wend
end
return
room6:
if rn = 6 then z = 1
end if
return
and here is the "name.bas" file thats gonna be my intro story line. the code above won't compile with out it.
dim as string player_name
locate 9
input "what is your name? ", player_name