Programming Text Adventures In Basic
Programming Text Adventures in BASIC Edit
Written By - Jonathan Skinner Edited and also Written by - Monarch
- Welcome to Programming Text Adventures in BASIC.
- Hopefully in reading this guide you will be able,
- to program your own text adventures.
What Will I Need? Edit
- I assume a basic knowledge of the BASIC programming language (please spare the puns).
- I also assume you are using a old BASIC interpreter or compiler such as Quick Basic, Free BASIC
- or Chipmunk Basic. (Qbasic is recommended only for Microsoft systems)
- I assume you are good at computers, play or played a text adventure before.
Starting to Code the Adventure Edit
So what are text adventures? What is interactive fiction? You've probably played Zork, Adventure, or many others. Interactive fiction or text adventures are very fun to play and communicate a great sense of environment to the player. They rely on story-telling, treasure finding, and sheer elements of adventure. If you have never played a text adventure, and would like to get an idea of what a text adventure is like exactly, here's a link to an online version of zork: http://thcnet.net/zork/index.php .
Now let's write a text adventure in Basic.
Note: when creating a game, you should code the introduction LAST. Dive straight into coding the game!
(You really don't need a REM for comments. As an alternative, start the line with a ' )
- Enter this Program into Your BASIC Interpreter or Compiler
REM INSERT TEXT ADVENTURE NAME REM BY INSERT YOUR NAME HERE 10 PRINT "WELCOME TO <YOUR TEXT ADVENTURE HERE>" 20 PRINT "PROGRAMMED BY <YOUR NAME HERE>"
(by this day and age, you don't need a number at the beginning of each line (no 10,20,30 on every line)
Remember, the journey of a thousand miles starts with a single step!
Coding Rooms: Arrays & Data Edit
Okay by now we have a introduction and a beginning, now we need a room. Of course, a room means anything a dungeon, a spacecraft, or a musty cavern filled with flesh-eating zombies.
To do this, you need a data array. In short, think of an array as a "storage bin". You know how for variables, you would use something like triangle = 9 or name$ = "Julius"? Well, an array is like an extended set of variables.
To use an array in your text adventure, you must first understand what an array looks like:
Here is an example of a simple data array that has 5 names stored and lists them on the screen:
CLS 'below is the array, using a FOR..NEXT loop to "store" the names contained in the DATA statements: DIM name$(5) FOR n = 1 TO 5 'also in the FOR NEXT loop is a PRINT statement, which will print the current value stored by name$ READ name$(n) PRINT name$(n) NEXT n DATA "James", "Beth" DATA "Fran", "Olivia" DATA "Bevan" 'feel free to copy this program and change it however you like! You can also make arrays that store number values as well!