Any tutorials about making text adventure games in windows?

New to FreeBASIC? Post your questions here.
chris00
Posts: 10
Joined: Jun 24, 2005 13:18
Location: england

Any tutorials about making text adventure games in windows?

Postby chris00 » Jun 25, 2005 9:02

Just wondering how easy it would be to programme, as I would imagine that it would just be a bunch of print and array commands, with if...then loops. Just wondering if there are any tutorials on this subject. Using the Windows version... Help would be appreciated
aetherFox
Posts: 100
Joined: Jun 23, 2005 16:48

Postby aetherFox » Jun 25, 2005 9:06

Na_th_an has written an excellent series which is running in QB Express. It is a detailed guide to writing modular, scripted IF games.
chris00
Posts: 10
Joined: Jun 24, 2005 13:18
Location: england

Postby chris00 » Jun 25, 2005 11:27

Started programming shortly after posting. The only worry for me is the inventory, but I have a theoretical method of avoiding that problem.
aetherFox
Posts: 100
Joined: Jun 23, 2005 16:48

Postby aetherFox » Jun 25, 2005 11:41

I wouldn't say that an IF is "just a bunch of Print statements with If..then loops". It's a lot, lot more than that. In fact, I personally think that IF games are some of the most difficult to program.
MystikShadows
Posts: 612
Joined: Jun 15, 2005 13:22
Location: Upstate NY
Contact:

Postby MystikShadows » Jun 25, 2005 12:12

I agree aertherfox, even if non graphical they often have the most complex structures and constructs to give it the A.I. it needs to make it a good game :-) <plug> like Quest for Opa Opa</plug> LOL
chris00
Posts: 10
Joined: Jun 24, 2005 13:18
Location: england

Postby chris00 » Jun 25, 2005 12:34

I have the if...then statements doing their job, but could you tell me how to make an updating Inventory, so I can program Items?
My coding is going well. This is what I've got so far:

Code: Select all

[start]
'display title and instructions
print "My First Game"
print
print "The commands you can use are North, South, East and West to travel in the "
print "respective Directions."
print "To Look at an area or piece of scenery in more detail, type EXAMINE"
print "followed by the object that you wish to examine"
print "To enter a cave or building, type ENTER, followed by the entrance that"
print "you wish to use"
print "The commands are case sensitive, so you must type the full phrase in "
print "all capitals."
print "Eg: EXAMINE CLIFF or WEST"
print
goto [forestRoom1]

[forestRoom1]
print "You are in a forest. You see a CLIFF face in the WEST. There are a"
print "lot of trees, most of them dying. You wonder what happened here"
print "There are exits NORTH and EAST."
goto [input]

'room just north of start
[forestRoom2]
print "the CLIFF continues on your WEST side, only to curve EAST and cut you off in "
print "the distance."
print "There are exits North, South and East."
goto [input2]

[forestRoom3]
print "This is where the cliff curves round to the east."
print "There is a CAVE with a SIGN next to it in the NORTH wall."
print "There are exits North, South and East."
goto [input3]

[forestRoom4]
print "The CLIFF stops abruptly to the east. The forest"
print "stretches out to the south."
goto [input4]

[forestRoom5]
print "There is what looks to be a ruin in the"
print "center of the forest."
print "There is writing on the ruin."
print "The forest branches out in all directions."
print "You can exit North, South, East and West."
goto [input5]
'cursor to give commands
[input]
input "What do you want to do? "; where$
if where$="EXAMINE CLIFF" then goto [examineCliff]
if where$="WEST" then goto [cannot]
if where$="NORTH" then goto [forestRoom2]
if where$="EXAMINE" then goto [examineWhat]
if where$="EAST" then goto [forestRoom6]
if where$="SOUTH" then goto [cannot]
[input2]
input "What do you want to do? "; where$
if where$="NORTH" goto [forestRoom3]
if where$="SOUTH" goto [forestRoom1]
if where$="EXAMINE" goto [examineWhat2]
if where$="EXAMINE CLIFF" goto [examineCliff2]
if where$="EAST" goto [forestRoom5]
if where%="WEST" goto [cannot2]
[input3]
input "What do you want to do? "; where$
if where$="ENTER CAVE" goto [caveRoom1]
if where$="NORTH" goto [caveRoom1]
if where$="SOUTH" goto [forestRoom2]
if where$="EXAMINE SIGN" goto [examineSign]
if where$="EXAMINE" goto [examineWhat3]
if where$="EAST" goto [forestRoom5]
if where$="WEST" goto [cannot3]
if where&="EXAMINE CLIFF" goto [examineCliff3]

[input4]
input "What do you want to do? "; where$
if where$="EXAMINE CLIFF" goto [examineCliff4]
if where$="EXAMINE" goto [examineWhat4]
if where$="WEST" goto [forestRoom3]
if where$="SOUTH" goto [forestRoom5]
if where$="EAST" goto [forestRoom9]
if where="NORTH" goto [cannot4]

[input5]
input "What do you want to do? "; where$
if where$="EXAMINE RUIN" goto [examineSign2]
if where$="EXAMINE" goto [examineWhat5]

[examineWhat]
print "What do you want to examine?"
goto [input]

[examineWhat2]
print "What do you want to examine?"
goto [input2]

[examineWhat3]
print "What do you want to examine?"
goto [input3]

[examineWhat4]
print "What do you want to examine?"
goto [input4]

[examineWhat5]
print "What do you want to examine?"
goto [input5]

[cannot]
print "You cannot go this way"
goto [input]

[cannot2]
print "You cannot go this way"
goto [input2]

[cannot3]
print "You cannot go this way"
goto [input3]

[cannot4]
print "You cannot go this way"
goto [input4]

[examineCliff]
print "The cliff has a mound of scree at the bottom. It towers"
print "over you like a behemoth."
goto [input]

[examineCliff2]
print "The scree pile is reducing in size. It is"
print "nearing your height."
goto [input2]

[examineCliff3]
print "There is a cave in the north wall"
print"and the cliff continues east, stopping abruptly."
goto [input3]

[examineCliff4]
print "The cliff remains large, yet slightly"
print "smaller than it was."
goto [input4]

[examineSign]
print "The sign says: 'Abandon Hope, all ye who enter"
print "here!' How cliche..."
goto [input3]

[examineSign2]
print "The writing on the ruin says:"
print "'This forest is doomed...Hear my plea..."
print "I have left clues around the forest and "
print "surrounding area"
print "that will help you solve the problem that we"
print "are faced with."
print " Angus Quatermaine'"
print "You wonder what he was on about."
goto [input5]
end


What do you think?
dumbledore
Posts: 680
Joined: May 28, 2005 1:11
Contact:

Postby dumbledore » Jun 25, 2005 13:44

it would be far easier to implement an inventory if you stored all the data in an external file and loaded it into an array or something so you could just reuse the same code for all the locations...
chris00
Posts: 10
Joined: Jun 24, 2005 13:18
Location: england

Postby chris00 » Jun 25, 2005 14:38

So my code is needlessly complex?
dumbledore
Posts: 680
Joined: May 28, 2005 1:11
Contact:

Postby dumbledore » Jun 25, 2005 14:55

i wouldn't say complex, just needlessly long...
aetherFox
Posts: 100
Joined: Jun 23, 2005 16:48

Postby aetherFox » Jun 25, 2005 15:15

Ummm, wow.

Don't take offense to this, but I can see you are still quite a beginner, so I wouldn't recommend taking na_th_an's tutorials on right away, they are fairly advanced, and gear towards writing robust IF engines.

Terry Cavanagh wrote a nice tutorial on text adventures a long time ago that I liked. It was the first thing that got me into them, and I used his tips and made my own game that was heavily modified from what I learned in that tutorial.

http://petesqbsite.com/sections/tutoria ... res_tc.txt

I have an incomplete game that is similar to the style of engine in there that was discarded when me and na_th_an formed Los Monos del Obús to make Opa Opa, but I'll be happy to send it to you.
dumbledore
Posts: 680
Joined: May 28, 2005 1:11
Contact:

Postby dumbledore » Jun 25, 2005 15:38

yes, that tutorial looks very good. here's your original code modified to be easier to add to, and far shorter, hopefully you can learn something from this too:

Code: Select all

option escape
'display title and instructions
print "My First Game"
print
print "The commands you can use are North, South, East and West to travel in the "
print "respective Directions."
print "To Look at an area or piece of scenery in more detail, type EXAMINE"
print "followed by the object that you wish to examine"
print "To enter a cave or building, type ENTER, followed by the entrance that"
print "you wish to use"
print "The commands are case sensitive, so you must type the full phrase in "
print "all capitals."
print "Eg: EXAMINE CLIFF or WEST"
print
type gamedata
    info as string
    validc as integer
    nextnode( 1 to 9 ) as integer
end type
dim as gamedata _data( 1 to 5 )
dim as string options( 0 to 9 )

for i = 1 to 9
    read options( i )
next

for i = 1 to 5
    read _data( i ).info
    read _data( i ).validc
    for j = 1 to 9
        read _data( i ).nextnode( j )
    next
next

data "EXAMINE RUIN", "EXAMINE SIGN", "ENTER CAVE", "EXAMINE CLIFF", "NORTH", "EAST", "SOUTH", "WEST", "EXAMINE"
data "You are in a forest. You see a CLIFF face in the WEST. There are a\nlot of trees, most of them dying. You wonder what happened here\nThere are exits NORTH and EAST."
data &b000111001
data 0, 0, 0, 0, 2, 0, 0, 0, 0
data "the CLIFF continues on your WEST side, only to curve EAST and cut you off in \nthe distance.\nThere are exits North, South and East."
data &b000111101
data 0, 0, 0, 0, 3, 5, 1, 0, 0
data "This is where the cliff curves round to the east.\nThere is a CAVE with a SIGN next to it in the NORTH wall.\nThere are exits North, South and East."
data &b011111101
data 0, 0, 0, 0, 0, 5, 2, 0, 0
data "The CLIFF stops abruptly to the east. The forest\nstretches out to the south."
data &b000101111
data 0, 0, 0, 0, 0, 0, 5, 3, 0
data "There is what looks to be a ruin in the\ncenter of the forest.\nThere is writing on the ruin.\nThe forest branches out in all directions.\nYou can exit North, South, East and West."
data &b100011111
data 0, 0, 0, 0, 0, 0, 0, 0, 0

dim as integer curnode = 1
while curnode > 0
    dim as integer found
    print _data( curnode ).info
    input "What do you want to do? "; where$
    for i = 1 to 9
        if where$ = options( i ) then
            if bit( _data( curnode ).validc, 8 - ( i - 1 ) ) then
                curnode = _data( curnode ).nextnode( i )
            else
                print "You cannot go this way"
            end if
            found = 1
        end if
    next
    if found = 0 then print "Unknown command."
wend
chris00
Posts: 10
Joined: Jun 24, 2005 13:18
Location: england

Postby chris00 » Jun 25, 2005 15:43

AetherFox I can't get my head around it. I type it in the same way the tutorial tells me to but I get a syntax error or type mismatch no matter how I type it.
aetherFox
Posts: 100
Joined: Jun 23, 2005 16:48

Postby aetherFox » Jun 25, 2005 16:00

OK, here is a game that I discarded (the one mentioned before), that I wrote for helping a friend into BASIC as well.

http://avinash.apeshell.net/stuff/code/siyana.bas

It should be easy to modify. I was going to do it using DATA statements, but this way is easy to understand.

It doesn't have an items handler yet, but you should be able to get that from Terry's article. If not, I might consider writing it.
chris00
Posts: 10
Joined: Jun 24, 2005 13:18
Location: england

Postby chris00 » Jun 26, 2005 4:50

I've found the problem. I'm using JustBasic for Windows, so Syntax may be slightly different to FreeBasic. Any ideas on how to make it work in windows?
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Postby DrV » Jun 26, 2005 4:56

Door #1: Use FreeBASIC instead
Door #2: Talk to the JustBasic people

:)

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 2 guests