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 / Help me please!

Author
Message
1337 programm3r
17
Years of Service
User Offline
Joined: 19th Nov 2007
Location: Your MOM
Posted: 24th Feb 2008 23:55 Edited at: 24th Feb 2008 23:57
so, im making a text game, and Im getting along alright(I guess) after reading some turorials ive found that the best way is to use arrays, to store the rooms in. Well, I might as well show you what I have befoer I ask what I need help with.



I believe it was somewhere on this forum, that I heard a good method is to assign numbers to the north,south,east,and west(which direction each area is in). What I cant figure out how to do is to switch to a different area. I know that the showroom function works nice . Also, right now im planning that when you move to a new room the text of the previous room just gets deleted, does anyone know how to make it scroll down? Also all the room descriptions are just to fill, Im still writing all the room descriptions.

ps. I dont really get how to identify commands, should I also put them into arrays?

Super Cool
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Feb 2008 02:46 Edited at: 25th Feb 2008 03:10
The way you'd move around the world depends on how you would store the world in the array.
If you use a 2D coordinate system, that stores separate values for X and Y positions, you can't simply assign a variable to move. You'd need a conditional statement:

Quite a lot of code is needed and each direction has to be hard-coded into the program. Say you later wanted to be able to move diagonally NW, NE, SE or SW; you'd have to hard-code those extra movements.

The way I would do it would be to have a 1D co-ordinate system.
I explain how to do this in another thread 1D Co-ordinates
Since you are using an array you don't have his "0" problem, you can use field 0 in arrays.

This way of storing the world makes moving in any direction easy.
Here is a diagram to help you understand how it would work

Each number on the "map" represents a room (I'm not expecting you to make 100 rooms ) and a field in your array.

Choose a point on the "map" to start from (preferably near the middle).
Move your finger north one place, your room number has just decreased by 10. Move your finger east and it will increase by 1. West decreases by 1 and South increases by 10.
Try this anywhere on the board and the difference is the same.

Therefore, North=-10, South=+10, East=+1 and West=-1

Now lets see how we'd move with this type of array

We've condensed the adjustment into a single line!
and we could also move diagonally by pressing two keys.

BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 25th Feb 2008 03:16 Edited at: 25th Feb 2008 03:18
I was working on a text adventure a while back, unfortunately lost the code to a virus, but I still remember how I worked the typing (text parser) and the movements.

First, motion:

I used a coordinate system in which going north would add 10 to your location value and right would be 1. That way you could just reference one number to figure out what message to display (I used file commands to get info about each map and the descriptions for each).

Text parser:
This was kinda complicated but after about a week and a half of solid coding I finally got it to work perfectly.

Here is the algorith:
1. Divide the statement into words
2. Store words into an array
3. Check each word against a master word bank (downloaded) for spelling issues
4. Check each word until the verb (go, walk, search, look) is found
5. Assign a number to an action variable to determine what to do
6. Scan the words again for the noun/direction (north, forward, chair, cup, etc)
8. Make sure that the noun exists in the environment (file exist command)
7. That word directly effects the path of the file it references for a description (C:/...Game/map/LOCATION/VERB/NOUN.txt)
8. Perform the action (Move, look, pull, etc)


The master word list can be downloaded free. I would post it as a download, but again, lost it to a virus.

Let me know if this makes sense or if you need anymore clarification as to my file structure.

Hope this helps!
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Feb 2008 03:25
@BN2
That is an interesting way of using file structure, would work well with my 1D map too

1337 programm3r
17
Years of Service
User Offline
Joined: 19th Nov 2007
Location: Your MOM
Posted: 25th Feb 2008 04:01
@obese, are you able to assign arrays to data statements? Wouldnt the way that you showed me mean that I would have to organize my map in an even square? Also would I need to asign each array that I have so that room1 one is west and room 10 is south?

for example


is that what you mean?

Super Cool
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 26th Feb 2008 01:46 Edited at: 26th Feb 2008 02:46
Quote: "@obese, are you able to assign arrays to data statements?"

not really sure what you mean.
You can assign the data in data statements to arrays
e.g.


Quote: "Wouldnt the way that you showed me mean that I would have to organize my map in an even square?"

No, the shape of the map depends on its width, but it would have to be rectangular. Why is that a problem though? If you don't want to use certain squares then leave them blank

16 rooms, width=4


16 rooms, width=8


16 rooms, width=2


If you use a width that isn't a factor of the total number of rooms the last row will be uneven.

16 rooms, width=5

Maybe you want it like that but in my eyes it doesn't look too good.

Quote: "Also would I need to assign each array that I have so that room1 one is west and room 10 is south?
"

I don't really understand you there
You don't need to change the room numbers, if you are at room 12, then going south would take you to room 22, you don't have to travel in a straight line through all the rooms.
This is a free-roaming RPG right?

I'm making a short example to show you how to move between the rooms...

[edit]
Haven't finished the movement part yet but it hints at how it would work.


1337 programm3r
17
Years of Service
User Offline
Joined: 19th Nov 2007
Location: Your MOM
Posted: 26th Feb 2008 02:49 Edited at: 26th Feb 2008 02:49
Lol I know I can be a little hard to understand sometimes, but im pretty sure I understand what your saying now. Thanks, and ill love to see that example you say your making

Super Cool

Login to post a reply

Server time is: 2025-06-04 02:01:16
Your offset time is: 2025-06-04 02:01:16