Text Adventure issues

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
MikeG
Newbie
Posts: 1
Joined: Sat Mar 27, 2010 10:31 am

Text Adventure issues

Post by MikeG »

Hi I'm mike and im new with qbasic (and this site) but im trying to make a text adventure but Im having trouble in two areas of this. Im going to try and explain this the best I can so bear with me here.

So pretty much I have the user in this area. and he has the ability to do different things when the command is put in. So i explain the situation and using a SELECT CASE... END SELECT scenario so they have the ability to enter their input. the problem is, when they type in one of these commands, it gives the printed response but then the game ends. I need to find a way to have it ask the original question once a command is entered so it doesn't immediately end after the "wrong" answer is chosen.

Also, When the "correct" answer is chosen I have it go to RSP2 (response2) in which it does print the question, but the game ends. I have it go from question 1 to 2 by PRINT "BLAHBLAHBLAH", RSP2. it does that fine but it wont let the user respond to the next question. I dont think Im explaining this well so Im gonna lay out some code from beginning to end.

DIM RSP1 AS STRING
DIM RSP2 AS STRING 'remember RSP# for me means a "correct answer"

CLS

PRINT
PRINT
PRINT "Hello, you've entered my house. you see a TV and a DOG. :"
INPUT "What will you do?:', RSP1

SELECT CASE RSP1
CASE "TV"
PRINT "Its a nice t.v. you turn it on and get bored, time to leave."
CASE "DOG"
PRINT "You pet the dog, and it has a nice fur coat.", RSP2

'this is where my first problem arrives, I don't know how to get it to ask that original input again OR how to place the CLS after that. if I select T.V. the game just ends, I want it to ask that question again of "what will you do?".

SELECT CASE RSP2
CASE "Go upstairs"
PRINT "You walk up the stairs to see a large WINDOW and a DOOR.
END CASE

'Second problem, after this happens it will print RSP2 but not give me the chance to respond to it.

So thats it.. Im sorry If you have no idea what im saying but im new at this. If you really want an idea of what i want. think of a text adventure such as this one :www. homestarrunner .com/ dungeonman . html

Thank you very much for your time and help. If im using a totally wrong code in general, if you could guide me to a form with the proper programing that would be much appreciated, thank you.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

There is no such thing as END CASE.

Make a main loop to repeat the code and work from there.

' setup screen

DO




LOOP UNTIL 'some user action to exit program
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Post Reply