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.

Newcomers DBPro Corner / I could use some advice/help with my text adventure.

Author
Message
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 12th Jun 2005 07:21
This text adventure is a translation from "old line numbered basic". My intention was to convert it to DBpro as part of a tutorial for introduction to text adventures. It seems I have worked myself into a dilemma.

The original code was complete spaghetti. I tried to do my best in the beginning to get some organization, and convert the game to a more modern game loop. Unfortunately some of the spaghetti code followed me.

Here's the code at current.



I don't know whether I should just continue as is and finish it; And then attempt to clean it up. It's obvious that using "User Define Types" ie. roomtype; would have kept things together more. So is this code salvageable? It's hard for me to be objective because I look at it with such disgust right now.

I fear that If I start over from the beginning, I won't have the drive to finish it.

At the time I began this, I was trying to help someone who had a questions about text adventures. I thought I could save myself some time by using this old resource that I had from my days with Commodore Basic. I now realize it would have been easier for me to design it from scratch.

note:
It's suppose to serve as a basic example. My real goal is to build an adventure building program that will make creation of these type of programs easier in DBpro.

If anyone has any advice I would really appreciate it. If you got this far, thanks for even looking at this.

~zenassem

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Jun 2005 08:39
It's not that bad, I've seen far worse!

I would definitely put the Types in, makes it easier to understand.

This may be personal preference, but I find functions easier to follow, and neater.

BatVink
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 12th Jun 2005 08:46
Thanks BatVink.

Yeah, I like functions as well. It's just that I hate trying to come up with multiple names of variables inside and outside functions. But I'll probably do that now.

And the user defined types. I'll hate myself if I leave it like this.

I'll just have to change my arrays, beacause I'll have an array of roomtypes rather than the way it is now.

Here's the lesson:
I should have done it "right" from the beginning.
My laziness always comes back to bite me.

~zenassem

RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 12th Jun 2005 11:35 Edited at: 12th Jun 2005 11:37
I would suggest converting to UDT's as well. I've had to do this before and it's a bit of work. Use of the Find/Replace might make it a little easier (I was able to when I converted).

Quote: "I should have done it "right" from the beginning."


Not sure this is the wrong way though. If you do want to go the "Adventure Building Program", you might find that arrays will just work better - because what they lack in readability, they make up for in flexibility. Example: Let's say you want a potion that increases a random character stat and you have a UDT arrray like so:

Type stats
str as integer
dex as integer
con as integer
int as integer
wis as integer
Endtype
Dim Characters(50) as stats

To randomly select one of the stats, you would probably use Select / Case, which can be a bit of coding. If the Array was "Dim Characters(50,5) then you can select a random stat using a single code line: Characters(50,rnd(4)+1) or whatever.

And functions - a definate must. I also usually start out just coding, then dividing sections of code up into functions. Some times I can visualize ahead and know I'll need a function for something specific, but most of the time - I accept recoding into functions as a normal step in the evolution of my code.

Edit: I like your work so far. Don't give up. If you want some help converting the code, I'll volunteer.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 12th Jun 2005 12:00
Riddi,

Thanks for your analysis. I really appreciate it. I also like your insight into the flexibility the array approach will have later on.

I was working on functions first anyway, mainly because I feared rearranging the structure of the arrays into arrays of a UDT.

Your comments have helped motivate me to see this through. Thank you.

I'll post when I get it cleaned up a bit, and get the other commands coded. I may ask for your help at that point, even if to just offer suggestions for organizing it.

Sincerely grateful,
~zenassem

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 12th Jun 2005 16:59 Edited at: 12th Jun 2005 17:49
I haven't done a text adventure game in Darkbasic yet, but I have done one in Quickbasic. What i've found is that it's SO much easyer to have the program load data from a text file rather than have all the data in code. It's easy to change anything you want without having to worry if you forgot a quote or comma. This was made to emulate the best text adventure game makers ever... Infocom.
The following isn't code but a note file with the data structure and an example under each:


-=> ROOM DATA
(room number)
0 (N) Note: Negative numbers in directions mean there are movement blocks like
1 (S) doors, unusual walls, cliffs to death, and various other things to show a better story.
2 (W) Like: -1 = The door is shut
3 (E) -2 = You try to go up the ramp but you slide back down
4 (NW) -3 = { Death #2 }
5 (NE) .-4 = You step into the teleporter
6 (SW) .{ RoomNumber = 7 }
7 (SE)
8 (UP)
9 (DOWN)
10 (IN)
11 (OUT)
12 (lighted? 0=dark 1=lighted)
13 Note: The last piece of data that is not there shows if the room has been visited or not. (in code only)
(ROOM NAME)
(DESCRIPTION OF ROOM... SEVERAL LINES)

1,0,2,0,6,0,0,0,0,0,0,0,6,1
Command Center
You are in the command center of the space ship Cheops. Your robot pilot
is inactive with a mass of wires covering him like Lilliputian ropes. From
here you can see the smashed console and to your right a lone, blue button
stands out. A gaping hole is to the west and an exit is to the south.


-=> ITEM DATA
0 (object location +500 if in another object)
1 (object weight)
2 (Can item be worn? 0=No 1=Yes but not worn 2=Yes and worn 3=Yes and bolted on
3 (Can the item be opened? 0=No 1=Yes and closed 2=Yes and opened
4 (weight limit... only used for containers)
5 (current load of items inside)
6 (Can item produce light? 0=No 1=Yes but off 2=Yes and is on 3=Yes but spent
7 (Number of turns the item can produce light)
(ITEM NAME... THE TEXT IT RECGONIZES)
(text for inventory viewing)
(text for item on floor in room)
(text for looking at the item... several lines)

20,15,0,0,0,0,0,0
DIAMOND
a diamond
A beautiful diamond is on the floor.
It's a flawless diamond about the size of your hand...too bad it's
3010. In the 20th century you would have gotten about 5 million of
the green pieces of paper they called money. Now it’s worth less than gum.


-=> LOOK DATA
(Room Number of non inventory objects 0 = anywhere)
(Keyword Name for that room)
(Description Text SEVERAL LINES)

0
SKY
In the distance you see an yellow ball of light.

1
ROBOT
The robot doesn’t look too good.


-=> TAKE DATA
(Room Number of non inventory objects 0 = anywhere)
(Keyword Name for that room)
(Description Text SEVERAL LINES)

0
ME
I would but you’re not my type.

1
WIRES
Bzzzzzzttt. Yooww!


-=> WORD DATA
(Word Number SAME NUMBERS = SAME MEANING)
(Word)

1
INVENTORY

1
I

2
LOOK

2
L

3
GET

Login to post a reply

Server time is: 2024-09-23 21:22:51
Your offset time is: 2024-09-23 21:22:51