I am currently busy with Nanowrimo, and in the story, there is a program that lets student write their own interactive stories. Even knowing how little it takes to do it, I'm rather surprised at the economy of it. Here is the program in its entirety:
- REM INIT
- CLEAR:TITLE$=""
- DIM TEXT$[10]
- DIM PAGE$[4]
- DIM MENU$[4]
- CH=0:P$="INTRO"
- @SHOWPAGE
- RESTORE P$
- READ TITLE$
- READ TEXT$[0]:READ TEXT$[1]
- READ TEXT$[2]:READ TEXT$[3]
- READ TEXT$[4]:READ TEXT$[5]
- READ TEXT$[6]:READ TEXT$[7]
- READ TEXT$[8]:READ TEXT$[9]
- READ PAGE$[0]:READ MENU$[0]
- READ PAGE$[1]:READ MENU$[1]
- READ PAGE$[2]:READ MENU$[2]
- READ PAGE$[3]:READ MENU$[3]
- REM DISPLAY
- CLS:?TITLE$:?
- ?TEXT$[0]:?TEXT$[1]
- ?TEXT$[2]:?TEXT$[3]
- ?TEXT$[4]:?TEXT$[5]
- ?TEXT$[6]:?TEXT$[7]
- ?TEXT$[8]:?TEXT$[9]
- ?"1",MENU$[0]
- ?"1",MENU$[1]
- ?"1",MENU$[2]
- ?"1",MENU$[3]
- REM INPUT
- INPUT CH:CH=CH-1
- P$=PAGE$[CH]
- GOTO @SHOWPAGE
If the structure isn't clear to you, you need to add LABEL and DATA statements. Here's a sampling that I have. Notice, the DATA segments do go on, although each having the same structure.
- REM WINDELL
- @INTRO
- DATA "THE STORY OF WINDELL"
- DATA "ONCE UPON A TIME THERE WAS A"
- DATA "LITTLE RAT BY THE NAME OF"
- DATA "WINDELL."
- DATA " "
- DATA "SHE WAS HUNGRY AND IN SEARCH"
- DATA "OF CHEESE. WHERE DO YOU THINK"
- DATA "SHE SHOULD GO?"
- DATA " "
- DATA " "
- DATA " "
- DATA "KITCH","TO THE KITCHEN"
- DATA "BEDRO","TO THE BEDROOM"
- DATA "BADEND","STAY HOME"
- DATA "INTRO"," "
The DATA segments consist of a LABEL, 1 line TITLE, 10 lines TEXT, and 4 lines LABEL/CHOICE combo. Obviously there's also @KITCH, @BEDRO, and @BADEND DATA segments. There's also @GOODEND data segment, too!
The beauty of it is that the story can be long and involved. The size of the program stays the same regardless. This is a good introduction for computer programming, those of you who are just beginning. Obviously, it can be refined further. How about full screen text on top, and 8 or more choices on the bottom? Simple enough to enhance and experiment with.
No comments:
Post a Comment