I was thinking about making a choose your own adventure. What would be the best way to structure the code? I am very new, and they only two ways I could think of was making menus after the text where you could choose your own choice.
The other option was if/then that led to different Lbls. What do you think?
You could ask JWinslow23 how he made his text adventure. In his, you type in simple English commands, and the program will respond.
I'd do menus, with text and a press enter to go to the menu thing (Disp text and Pause, user presses enter and is taken to a menu). The menu could be a custom one, or the TI-BASIC Menu( command
If this was done on the graphscreen, it'd look really nice, but if not, you can still make it look cool. I was also thinking of another way you could do it, which is that the options would be displayed on the screen, and the user could either use numbers to select, or use arrow keys to control a cursor. If not that, then you should just stick with the menu/label idea.
jcgter777 wrote:
If this was done on the graphscreen, it'd look really nice, but if not, you can still make it look cool. I was also thinking of another way you could do it, which is that the options would be displayed on the screen, and the user could either use numbers to select, or use arrow keys to control a cursor. If not that, then you should just stick with the menu/label idea.

I've seen programs that use the graph screen, but I'm not sure how that works.
21tmccauley wrote:
jcgter777 wrote:
If this was done on the graphscreen, it'd look really nice, but if not, you can still make it look cool. I was also thinking of another way you could do it, which is that the options would be displayed on the screen, and the user could either use numbers to select, or use arrow keys to control a cursor. If not that, then you should just stick with the menu/label idea.

I've seen programs that use the graph screen, but I'm not sure how that works.


You just use Text( and/or TextColor(

For example:

Code:

TextColor(BLACK
Text(1,1,"Hello World!
jcgter777 wrote:
21tmccauley wrote:
jcgter777 wrote:
If this was done on the graphscreen, it'd look really nice, but if not, you can still make it look cool. I was also thinking of another way you could do it, which is that the options would be displayed on the screen, and the user could either use numbers to select, or use arrow keys to control a cursor. If not that, then you should just stick with the menu/label idea.

I've seen programs that use the graph screen, but I'm not sure how that works.


You just use Text( and/or TextColor(

For example:

Code:

TextColor(BLACK
Text(1,1,"Hello World!

Ok thanks!
You can use the menu command:

Menu("TITLE","CHOICE 1",LABEL,"CHOICE 2",LABEL

Or you can use Input and detect commands:

Input "? ",Str0
(The "? " Is just what it displays before the input box)
If Str0="INSPECT"
(If the player types "INSPECT")
Then
INSPECT COMMANDS
Else
If Str0="LEAVE"
(If the player types "LEAVE")
Then
LEAVE COMMANDS
Else
(If the player typed something that isn't a command)
ELSE COMMANDS
End
Oh boy. This post might be long.

Welcome to Cemetech, 21tmccauley! Glad to see someone starting to learn TI-BASIC!

As far as I know, there are two ways to make a text adventure: with many many menus, or with text input.

The first method, if you've read a Choose Your Own Adventure book, is the most straightforward to understand and code, but the program might get messy and tangled. At each step, you are shown text, and given a choice between two or more options. If one option is selected, you progress to one certain point, and if the other is selected, you progress to another.

In order to use this method, you need menus. Lots and lots of them. You can either use the Menu( command, or you can make your own menu routine. Here is some example code.

Code:
ClrHome
Disp "IN THE DEPTHS OF THE","FOREST. THE FALLING SNOW","SWIRLS AROUND THE OLD ASH","TREES PLAYFULLY. SOUNDS OF","WATER CAN BE HEARD THROUGH","THE BUSHES TO THE WEST."
Pause
Menu("WHAT DO YOU DO?","GO NORTH",N,"GO SOUTH",S,"GO WEST",W,"GO EAST",E)

blah blah blah code

Lbl N
"stuff to do if you go north"

Lbl S
"stuff to do if you go south"

etc.

This is just fine if your storyline would be similar to a book. However, the simplest form of this method gives the player no more interaction than navigating through a DVD menu, so you will need to find a way to improve it. Perhaps set a variable if a certain path was chosen, then later in the game, do something different depending on that variable. Maybe offer multiple endings based on whether or not certain items were picked up along the way.

The second method, while it offers more flexibility on the player's part, is much harder to code. At each step of the way, instead of going through a pre-determined list of story paths, the player can input whatever they want to do at any time (which may or may not advance the story).

In order to use this method, you need to take user input. You can either use Input, or you can make your own input routine. Receiving input isn't hard, but then you must decide what to make the program do based on that input.

Input processing is by far the hardest part of the actual coding of a text adventure. In my text adventure game, 8K Adventure, input processing alone takes about 700 bytes of code! However, that was a somewhat more sophisticated text parser that processes word-by-word, understands many synonyms, and ignores words it doesn't know (i.e. TAKE KEY, GET THE KEY, and PLEASE TAKE THE SHINY KEY I WANT IT are all understood as equivalent). This will probably be overkill for a very simple text adventure, however, I propose you do something else instead.

Code:
ClrHome
Disp "SURROUNDED BY BUSHES ON","THE EAST BANK OF THE RIVER","BURRE. OVER THE ICY WATERS","YOU CAN SEE THE FLICKERING","OF A DISTANT LIGHT. A","SMALL BOAT SIMILAR TO A","CORACLE IS TIED HERE."
Input ">",Str1
" "+Str1+" "→Str1
If inString(Str1," WEST "):Then
"stuff to do if you go west"
End
If inString(Str1," EAST "):Then
"stuff to do if you go east"
End
If inString(Str1," EXAMINE BOAT ") or inString(Str1," LOOK AT BOAT "):Then
"stuff to do if you look at the boat"
End
If inString(Str1," CUT ROPE "):Then
"stuff to do if you cut the rope"
End

Using the inString() command, and accounting for some common forms of commands, you can make a pretty effective text parser. Note that this will not give you a linear story, so you will need to have variables that keep track of how far along in the story you are.

Obviously the code given for both examples will need many more parts to them to make them completely work, but I'll leave most of it for you to discover. If you have any questions, just ask!

Hope I helped!
WOW! This is more than I could have asked for Very Happy. This answers so many questions, and gives a me few more. I am excited to learn to use these new features, and maybe produce something not half bad for a beginner. Thank you very much.

Edit by admin: please don't quote huge posts
If I have a name stored in a string, how would I have it show in a Disp.

Disp "hello" [name in string1]
You can use + to combine string: Disp "Hello, "+Str1
c4ooo wrote:
You can use + to combine string: Disp "Hello, "+Str1

Ok, thanks. There are so many things I have never even thought to try Smile
try them! try them all! the great thing about BASIC is that it'll tell you where errors are, and with a C[S]E, syntax help is actually helpful.
What can I do to start reducing the size of the program? So far this is what I have, and it is already 1kb

Code:

ClrHome
Disp "Welcome to your life."
Disp "First things first:"
Wait 3
Menu("Will you be born","Yes ",A,"No ",B
Lbl A
ClrHome
Disp "Congratulations!","You're alive"
Wait 3
ClrHome
Disp "What is your name?"
Input ">",Str1
If inString(Str1,"DAVIS"):Then
ClrHome
Output(5,9,"Game Over"
Wait 3
Disp "Sorry Davis :)"
Wait 2
Return
End
If inString(Str1,"MR HANSEN"):Then
Disp "Now this is a very special","story"
Wait 3
prgmMRH
Else
Goto D
Lbl B
ClrHome
Output(5,9,"Game Over"
Wait 3
Goto C
Lbl C
Disp "What did you think would","happen?"
Wait 3
ClrHome
Lbl D
ClrHome
Disp "Hello, "+Str1
Disp "Welcome to life. Do","you want to go to","school?
Wait 4
Menu("School","Yes ",E,"No ",F
Lbl E
ClrHome
Disp "Welcome to elementary school.","Here you will spend 8366.4","hours of your life learn","ing some useless math","skills"
Wait 5
ClrHome
Disp "You've made it to Jr.","High. Here you will make","friends, or learn a lot"
Wait 4
Menu("How will you spend your","time","Friends",G,"Knowledge",H
Wait 4
Lbl F
Disp "You've choosen a rough","path. You already weren't","the brightest, and this","won't help"
Wait 4
Disp "Now you live in the streets","and you see some sketchy","people. One of them approaches","you"
Menu("Do You Approach","Yes",I,"No",J

Code:
Menu("How will you spend your","time","Friends",G,"Knowledge",H
Wait 4

This wont work for menus, the title has to fit on one line.

Code:
Menu("How'll you spend your time","Friends",G,"Knowledge",H
Wait 4
should work Smile
You should store common text in strings to easily recall, like Game Over.
jcgter777 wrote:
You should store common text in strings to easily recall, like Game Over.

How would I do this? I tried:

Code:

Output(5,9,"Game Over")->Str1
Disp " "+Str1

This is obviously wrong, but it was the only thing I could think of.
21tmccauley wrote:
jcgter777 wrote:
You should store common text in strings to easily recall, like Game Over.

How would I do this? I tried:

Code:

Output(5,9,"Game Over")->Str1
Disp " "+Str1

This is obviously wrong, but it was the only thing I could think of.

Here Smile


Code:
"Game Over->Str1
Output(5,9,Str1
Disp " "+Str1


Basically, you store the string to Str1, then output at row 5, column 9 the contents of Str1, and then display the string " "+Str1, which is Str1 with an extra space at the beginning.

A neat feature of TI-Basic lets you omit ending parenthesis and quotes when you are at the end of a line, or before a store mark.
In the editor on the computer, what do I use to store something? When use >,->, or anything else, it doesn't work.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 4
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement