Inventory in a simple text adventure.
Posted: Thu Jan 21, 2010 10:24 pm
So I'm a beginner to QBASIC, and coding in general. After completing the first tutorial here on Pete's site, I played around with it, making some aesthetic modifications and adding different difficulties. Then I made a simple program which generated lottery numbers randomly. My third program is my first "real" project. It's a text adventure following a day in the life of a freshman student at my high school. It is not graphical in any way...I'm a story writer, so the idea was to make an interactive book. I will provide the code for the first scene so you can get an idea of the style.
Anyway, as you can see, I'm working with minimal knowledge. I'm not looking for too much....honestly I could complete this if I could just get the inventory figured out.
I want to implement a very simple inventory system. By typing "BACKPACK" at any point in the game, I want the user to be taken to a simple list of the items he/she has obtained. The user will be able to obtain these items (which will be necessary to complete other parts of the game) by "PICK UP"ing them.
For example, the user could find a spoon early in the game, then later on an NPC will need a spoon so that other events can be triggered.
So I already know how to make a screen with a list, but how could I have the computer automatically add certain words to the list when the user "PICK UP"s them?
Then, how could I have the computer check to see whether or not there is a specific item in the list so that the user can "GIVE TO" this item to trigger another event?
I was brainstorming, and I was thinking you could have it assing the string variable a certain numeric value, then check for that numeric value when it is needed.
But I don't know. Any suggestions?
EDIT: The message board got rid of all the spaces that spaced out the ASCII art and all of the paragraph formatting.
'\\\\UNTITLED TEXT ADVENTURE////
'This will be some sort of text adventure involving a day in the life of a
'Fountain-Fort Carson High School Student
PRINT " ____________
PRINT " |____ ____| _______ __ __ ___ _______ ______
PRINT " | | \ | || \ | || \ | || \ 's
PRINT " _ | | B || ____|| \ || D || ____|| RR |
PRINT " | | | | / | |_ | |\ || D || |_ | __/
PRINT " | |__| | \ | _} |__| |__||____/ | _} | \ \
PRINT " |_______| B || |_____________________| |____ | | \ \
PRINT " (c)2009|_____ / |________________________________||__| \__\
PRINT " _
PRINT " / \
PRINT " / /_\ \
PRINT " / _____ \
PRINT " /___/ \___\
PRINT " _________ _________
PRINT " |___ ___| |___ ___|
PRINT " | | | |
PRINT " | | | |
PRINT " |_| ROJAN |_| ALE
PRINT " FRESHMAN YEAR
INPUT " Press any button to play. " , a$
IF a$ = "" THEN GOTO 10
10 CLS
COLOR 15
PRINT " It still seems as though you were just getting out of school"
PRINT " yesterday, but summer has already faded away. You feel as "
PRINT " though you wasted the time that was given to you. Now you are"
PRINT " starting at a new school: Fountain-Fort Carson High. "
PRINT " As the car approaches the school, you feel the sensation of"
PRINT " encroaching doom. What could you possibly do to avoid starting"
PRINT " high school so soon? Maybe you could jump off a cliff and break"
PRINT " your leg. No, you're parents would still make you go. Perhaps"
PRINT " you could gouge out your own eyeballs?"
PRINT " It's the day of freshman registration, and your mom sits next"
PRINT " to you, filling out some sort of medical form. She says you must"
PRINT " sign your name at the bottom."
COLOR 7
INPUT " (NAME): " , nm$
IF nm$ = "" THEN GOTO 10
15 CLS
COLOR 15
PRINT " After finishing the forms, you have your picture taken for your"
PRINT " School I.D. You talk to a few friends from the middle school, but "
PRINT " everyone seems too nervous to hold much of a conversation. You"
PRINT " get your I.D., and then you have to wait in the library to get your"
PRINT " laptop. After everything is finally taken care of, you return home"
PRINT " for your final week of vacation.
COLOR 11
PRINT " ONE WEEK LATER..."
COLOR 12
PRINT " BUZZ! BUZZ! BUZZ! BUZZ! BUZZ! BUZZ! BUZZ!
COLOR 7
INPUT " INPUT: " , c$
PRINT " For help, type "HELP"
IF c$ = "HELP" THEN GOTO 16
IF c$ = "TURN OFF ALARM" THEN GOTO 20
16 PRINT
PRINT " Try turning off the alarm "type commands in ALL CAPS"
20 CLS
Anyway, as you can see, I'm working with minimal knowledge. I'm not looking for too much....honestly I could complete this if I could just get the inventory figured out.
I want to implement a very simple inventory system. By typing "BACKPACK" at any point in the game, I want the user to be taken to a simple list of the items he/she has obtained. The user will be able to obtain these items (which will be necessary to complete other parts of the game) by "PICK UP"ing them.
For example, the user could find a spoon early in the game, then later on an NPC will need a spoon so that other events can be triggered.
So I already know how to make a screen with a list, but how could I have the computer automatically add certain words to the list when the user "PICK UP"s them?
Then, how could I have the computer check to see whether or not there is a specific item in the list so that the user can "GIVE TO" this item to trigger another event?
I was brainstorming, and I was thinking you could have it assing the string variable a certain numeric value, then check for that numeric value when it is needed.
But I don't know. Any suggestions?
EDIT: The message board got rid of all the spaces that spaced out the ASCII art and all of the paragraph formatting.