Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Simple Text Adventure

Author
Message
Wiley85
17
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 9th Jan 2009 22:23
Hello Everybloody! I just got DarkBASIC for Christmas and have been playing around trying to make a text adventure game. Unfortunately, my booklet tutorials focus more on graphics games and I can't really figure out an easier way to make a large text game other than a bunch of IF THEN statements. Someone I work with told me there's a way to make a sort of virtual map that my program can read so I can simply have a small block of direction commands rather than repeating the same code over and over. I can't for the life of me figure out the commands to accomplish this. I'll try to post my game onto this forum for viewing, but this being my first post, don't be surprised if it doesn't work. I appreciate any help anyone can give me in this matter. Thanks!
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Jan 2009 22:48
Wiley85
17
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 9th Jan 2009 23:52
Ok, that helps a bit, but I can't seem to make the type storage bit work. I have made an array of a few lines of text and options though and that seems to be working. Should I have mentioned that I am running DarkBasic v. 1.12?
BN2 Productions
22
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 10th Jan 2009 00:07
What kind of text adventure? Does it have a text parser (where you have to type "Look at boat") or just the "What do you want to do A) B) or C) " kind?

If it is the first, I would suggest doing the second one for simplicity reasons. For the second one, you can use if->thens or you could use the select command. I think that would be the best bet, though there are probably better ways of doing it.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Wiley85
17
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 10th Jan 2009 02:01
Hokay, I've gotten myself into a bit of a mess. I tried using arrays like the tutorial suggested and this is what I've got:
[href]undefined[/href]
rem User interface array
DIM Adventure$(5,6)
Adventure$(1,1)="You find yourself in the middle of a forest. A path runs north and south. You see smoke rising to the north."
Adventure$(1,2)="What do you do?"
Adventure$(1,3)="1. Follow the path North."
Adventure$(1,4)="2. Follow the path South."
Adventure$(1,5)="3. Walk West into the trees."
Adventure$(1,6)="4. Walk East into the trees."
Adventure$(2,1)="After walking into the trees, you have come to a cliff and must turn back."
Adventure$(2,2)="After walking into the trees, you emerge into a clearing. You think you see a cave entrance in the distance."
Adventure$(2,3)="What do you do?"
Adventure$(2,4)="1. Go towards the cave."
Adventure$(2,5)="2. Go back."
Adventure$(2,6)="You find a silver dagger inside a hollow tree stump. However, the path leads off a cliff and you must turn back."
Adventure$(3,1)="You discover a small cottage. The door is unlocked, and you can't see inside."
Adventure$(3,2)="What do you do?"
Adventure$(3,3)="1. Enter the Cottage."
Adventure$(3,4)="2. Keep following the path north."
Adventure$(3,5)="3. Go back."
Adventure$(4,1)="Inside a crazy old man jumps at you with a knife and cuts your throat!"
Adventure$(4,2)="And so ends your Adventure. Sorry!"
Adventure$(4,3)="Inside you are attacked by an old man wielding a knife. You make short work of him with your dagger."
Adventure$(4,4)="Upon looking around the cottage, you find a torch which is still warm."
Adventure$(4,5)="Having successfully looted the cottage, you exit to the path. What now?"
Adventure$(4,6)="1. Go back."
Adventure$(5,1)="You are inside a cold dark cave. You can't see anything and must turn back."
Adventure$(5,2)="You are inside a cold dark cave. You light your torch and discover only one way; deeper into the cave."
Adventure$(5,3)="1. Go deeper into the cave."
Adventure$(5,4)="2. Go back."
Adventure$(5,5)="Upon venturing deeper into the cave, you come across a large, open chest which contains tons of money."
Adventure$(5,6)="You found the Money! You Win! Yay!"

rem Inventory array
DIM Inventory(1,2)
Inventory(1,1)=0
Inventory(1,2)=0

rem Start of Adventure
AdventureStart:
CLS
PRINT Adventure$(1,1)
PRINT Adventure$(1,2)
PRINT Adventure$(1,3)
PRINT Adventure$(1,4)
PRINT Adventure$(1,5)
PRINT Adventure$(1,6)
INPUT " ",start

rem North selection - cottage
IF start=1
CLS
PRINT Adventure$(3,1)
PRINT Adventure$(3,2)
PRINT Adventure$(3,3)
PRINT Adventure$(3,4)
PRINT Adventure$(3,5)
INPUT " ",cottage
ENDIF

rem Cottage death
IF cottage=1 AND Inventory(1,1)=0
CLS
PRINT Adventure$(4,1)
PRINT Adventure$(4,2)
END
ENDIF

rem cottage loot
IF cottage=1 AND Inventory(1,1)=1
CLS
PRINT Adventure$(4,3)
SLEEP 3000
PRINT Adventure$(4,4)
SLEEP 3000
PRINT Adventure$(4,5)
PRINT Adventure$(4,6)
PRINT Adventure$(3,4)
Inventory(1,2)=1
INPUT " ",loot
ENDIF

rem South selection - dagger
IF start=2 AND Inventory(1,1)=0
CLS
Inventory(1,1)=1
PRINT Adventure$(2,6)
SLEEP 5000
GOTO AdventureStart
ENDIF

IF start=2 AND Inventory(1,1)=1
CLS
PRINT "The stump is empty, the cliff's still there."
SLEEP 3000
GOTO AdventureStart
ENDIF

rem West selection - cliff
IF start=3
CLS
PRINT Adventure$(2,1)
SLEEP 3000
GOTO AdventureStart
ENDIF

rem East selection - cave entrance
CaveEntrance:
IF start=4
CLS
PRINT Adventure$(2,2)
PRINT Adventure$(2,3)
PRINT Adventure$(2,4)
PRINT Adventure$(2,5)
INPUT " ",cave
ENDIF

IF cave=1 AND Inventory(1,2)=0
CLS
PRINT Adventure$(5,1)
SLEEP 3000
GOTO CaveEntrance
ENDIF

IF cave=1 AND Inventory(1,2)=1
CLS
PRINT Adventure$(5,2)
PRINT Adventure$(5,3)
PRINT Adventure$(5,4)
INPUT " ",deeper
ENDIF

IF cave=2 THEN GOTO AdventureStart


IF loot=1 THEN GOTO AdventureStart


HELP!!!
Wiley85
17
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 10th Jan 2009 06:28
clearly I am new and don't know what I'm doing right?
Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 10th Jan 2009 16:41


just paste your code, hilight it then hit the code button



also indenting your code makes it easier to read so this


would look like this:




i dont think i see anything your doing wrong. looks like a good start.
Wiley85
17
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 10th Jan 2009 16:58
really? thanks. I'ma try again with more organization.

for practice purposes, I'ma place a small bit of code here, just ignore it.



Thanks for all the help guys! I'll keep posting my progress, if there is any.
Wiley85
17
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 10th Jan 2009 17:42
MAJOR BREAKTHROUGH!!!

Ok, I was thinking, and I decided to use gosubs and loops to simplify my program, check it out:



am I on track now? I think this way might be much simpler and make for less if then statements and code lines. Yay!
pluto
18
Years of Service
User Offline
Joined: 18th May 2008
Location:
Posted: 10th Jan 2009 22:51
You may want to check out my tutorial, Create Zork.

http://forum.thegamecreators.com/?m=forum_view&t=129931&b=7

It teaches you from the ground up all the tricks of making a text adventure like zork and includes a sophisticated parser.
Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 10th Jan 2009 23:14
one other thing double posts are frowned appon lol use the "edit post" button
Wiley85
17
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 14th Jan 2009 01:08
Yay! My first real text adventure!
Bluestar4
20
Years of Service
User Offline
Joined: 19th Dec 2005
Location: USA
Posted: 22nd Jan 2009 18:23 Edited at: 22nd Jan 2009 19:23
not to kill your enthusiasm with dbc, but although you can do this kind of a project with dbc there are 2 drawbacks.
first, the exe size for this kind of project (text based adventure)
is overkill. I therefore suggest that if you wish to continue this project that you do it as a console app in c++ and/or c# as
The exe size wont be that large, and it wont require the kind of resourses that a dbc app would.
Now at some point you may want to expand the text adventure game to where its more like an "if" style game. then you could basically load bitmaps for each area to give the player a visual perception of what is going on. In this case dbc would be great for.
You could code your original in c+/c# then port it to dbc with the added graphics (just a suggestion)
a word of advice when doing these kind of projects, Always ensure that with each loop that your program goes through that it completely exits every function returns to the origianal caller, otherwise , your looking at unforseen crashes from memory losses caused from recursive errors. Some older compileres check for this , others do not, and in some cases the compiler is simply unaware because the coder is using goto and since goto jumps and it does not remember where it was the compiler might not report anything because its simply not aware. what are recursive errors ?
there are 3 main variations of this kind of error that you may or may not be aware of and the one to look out for the most is the second one. (in my opinion)

The first kind is where a function repeatably calls itself. as in , function a() calls function a() which will eventually hault the program from memery loss. symptoms inlcude the program haulting everytime on a given function.

A variation of this error and the most common is where functionA() calls functionb() which jumps/calls function c() which calls functionA() again (and the cycle repeats until there is no more memory) symtoms will be that the program crashes for no apparent reason or has a large memory leak somewhere.

The last variation has to do with include files and is more common in c++ but since dbc has the ability to use includes I am including that in this post also. In this variation a function in file a calls a function in file b which calls a function in file c which calls a function in file a. This last example is commonly named circular referencing. All of these are basically a form of recurrsion however, in the case of the second , one must usually visually step debug project with a dozen variable windows open to catch it as the program will halt on the first one and the compiler will usually catch the last one.
Again, since goto jumps without leaving a trace, I suggest that in the future you should avoid using goto altogather as using it can make the simplist of projects a diasterous nightmare.

bluestar4~
Wiley85
17
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 28th Jan 2009 20:13
Ok, first off, I'm new to db so I've still got a pretty tenuous grasp on the language, but I'm nowhere near understanding c# or c++ or any of that garble. However, I have made a few very slight changes to my program, and I will post my code here so you can see what I've done. Basically just saved a file of my array so it's not taking up so much room in my program, and because of this I won't place the download. If you wanna play the new version, lemme know and I'll post. Thanks everyone for all your help!

Login to post a reply

Server time is: 2026-07-05 11:52:46
Your offset time is: 2026-07-05 11:52:46