Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text Adventure!
#31
Code:
DECLARE SUB FindWord ()
DECLARE SUB FindPlace ()
SCREEN 16,,,1
SETMOUSE 1,1,0
TYPE inputs
   count AS INTEGER
   found AS STRING
END TYPE

DIM SHARED word(10) AS inputs
DIM SHARED cmd$
FindPlace
FindWord
SLEEP

SUB FindWord
  
   INPUT ">",userinput$ 'Get user input
   userinput$ = " " + userinput$ 'and add a space to find first word
   a = 1 'just another non-existent variable
   FOR I = 1 TO LEN(userinput$)            'go by number of letters
      IF MID$(userinput$,I,1) = " " THEN   'if it found a space, then
         words = words + 1                 'add another word,
         word(a).count = I + 1             'position of new word
         word(a).found = lcase$(MID$(userinput$,word(a).count, 3)) 'store the three-letter code
         a = a + 1
      END IF
   NEXT I
  
   'Search for command-------------------------------------------------
   RESTORE commands
   FOR J = 1 TO 21
      READ cmd$
      IF word(1).found = cmd$ THEN EXIT FOR
   NEXT
   IF word(1).found <> cmd$ THEN PRINT "I don't understand."
   '-------------------------------------------------------------------
  
   'Search for first item----------------------------------------------
   IF words >= 2 THEN
      
   END IF
  
   commands:
   DATA "n","s","e","w","nor","sou","eas","wes","tak","exa","i","inv","l"
   DATA "loo","kil","mov","pus","eat","thr","giv","put"
  
   items:
   'Weapons
   DATA "kni"
   'necessary items
   DATA "gla","fla"
   'expandable items
   DATA "poc","sac","bag","usb"
   'keys/special items
  
   prepos:
   DATA "wit","fro","at","to","by","on","und","ove"
  
END SUB

SUB FindPlace
   area = 1
   OPEN "area/" + STR(area) + ".txt" FOR INPUT AS #1
  
   INPUT #1,status
   PRINT status
   SELECT CASE status
   CASE 0
      COLOR 7
   CASE 1
      COLOR 9
   CASE 2
      COLOR 2
   CASE 3
      COLOR 4
   CASE 4
      COLOR 15
   END SELECT
  
   CLOSE #1
  
END SUB

This finds individual words. We should be able to put other stuff in a file and pull it up, the way I designed.
Quote:As a side note, I wish I was a robotic zombie ninja pirate.
Reply
#32
Quote:well the optimization I suggested had nothing to do with running speed, but with developing time reduction and simplification...

Now it makes sense... :roll:
Screwing with your reality since 1998.
Reply
#33
Just out of curiosity RADIUM-V Interactive why don't you use a += 1 instead of a = a + 1? Is one slower, just easier to read, or habit? I have a feeling this is a stupid question.
Reply
#34
They equate to exactly the same thing. It's just preference.
Reply
#35
+=1? That's new I use a=a+1 out of habit.
Screwing with your reality since 1998.
Reply
#36
If you want, I can help you guys with your project. I like text adventures, and I have a couple ideas on how to store information needed, like locations, objects, and actors. Just give me the go-ahead and I'll start.
url=http://www.freewebs.com/boxtopstuff/]Planet Boxtop[/url] (Look out for the redesign!)
The only member of QBNF with severe "tomorrow syndrome."
Reply
#37
Anyone's welcome, Waffle.
Quote:As a side note, I wish I was a robotic zombie ninja pirate.
Reply
#38
Good. Then I'll get started on the room loading code. What I suggest is that the location, object and actor information (name, description, what room they're in, etc.) be stored within outside files. That way, changes to the game can be made without mucking around with the code. However, I don't think this is the best way to do things, but it hasn't failed me (as of yet.)

I'll show you more when I'm finished.
url=http://www.freewebs.com/boxtopstuff/]Planet Boxtop[/url] (Look out for the redesign!)
The only member of QBNF with severe "tomorrow syndrome."
Reply
#39
I kinda set mine up that way - it can read the file based on the area variable, and input# the items based on line number and circumstance. :wtnod:

But, everybody's happy with the method of finding 3-letter word fragments for the actual keyword? That seems the easiest. Then we can just use general CASE calls?
Quote:As a side note, I wish I was a robotic zombie ninja pirate.
Reply
#40
Why not work out EVERY command and parameter you will use, then see if the three letter fragnment method will work?
Screwing with your reality since 1998.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)