|
-
Oct 12th, 2000, 04:50 AM
#1
Thread Starter
Addicted Member
Heres what I found to be the easiest way to program a movement system.
Create 2 arrays, one is your map, the other is your Character.
Dim CharacterArray(5)
Dim MapArray(10,10,1) ' this will allow for a set of squares, 10 by 10.
Then you need to setup the map array, you need to draw the 10 by 10 grid on paper, and draw your map on it using 1 square as a location. Then make a note on each square what exits are available, using N for north, S for south and so on. Then match up the grid locations, (i.e. 2(across),5(down)) and do...
MapArray(2,5,0) = "NS" ' this tells the program that the user can move North, and South
MapArray(2,5,1) = "An empty Street" ' This is the description of the location.
Then the character array contains this data.
CharacterArray(0) = "Allanon" ' There name
CharacterArray(1) = 0 ' There Across position in relation to the maparray
CharacterArray(2) = 0 ' There Down position in relation to the maparray
Then When a character requests to move, all you need do is this code...
If moverequest = "N" and instr(maparray(characterarray(1),characterarray(2),0),"N") Then
CharacterArray(2) = CharacterArray(2) + 1
End If
TO move south, just subtract 1 from that, and user characterarray(1) for moving east and west.
Then all you need to do it print out the description..
User.Screen.Caption = maparray(characterarray(1),characterarray(2),1)
You can expand on this lots, adding up and down, is very easy, and both the character array, and the map array can have any amount of extra data added to them.
Tony@Work.
-
Oct 12th, 2000, 09:31 AM
#2
Frenzied Member
Quite a neat and tiday way of doing it.
One point: wouldn't you be better off with a user-defined type for the character? You seem to be using the array to hold general information on the character, I think maybe a UDT would be more appropriate.
Harry.
"From one thing, know ten thousand things."
-
Oct 12th, 2000, 09:36 AM
#3
Thread Starter
Addicted Member
Most definately.. but for simplicity(Simpletons?) sake, I figured, array heh whats your opinion on a method of storing these arrays? Im was debating binary or text file, but then I realised that the character is constantly updated, so it needs to be written to the file on a regular basis, in case of crashes and the like.. :P
-
Oct 13th, 2000, 03:41 PM
#4
Addicted Member
Yep, it probably will crash a lot. Keywourd: MICROSOFT visual basic I agree with the user defined types thou. A lot more convenient than arrays.
[Edited by DarkMoose on 10-13-2000 at 09:52 PM]
To understand recursion, one must first understand the concept of recursion.
-
Oct 13th, 2000, 05:37 PM
#5
Frenzied Member
Seems like DarkMoose found the way to underline! lol
Sanity is a full time job
Puh das war harter Stoff!
-
Oct 13th, 2000, 06:17 PM
#6
Member
Heh ... surprised though I am to find stuff about text adventure games on a VB forum ... well, frankly, that's quite probably *not* the best way of doing it.
I say that mainly because in text adventure games rooms are very rarely uniform size. Going E-N-W-S will not always take you back to the same room. Plus, there's up, down, and any number of other directions.
A better method would be to have a one dimensional array of descriptions, array(s) to store any other info (including what items are there, etc.), and what room you'll end up in for each direction you can go.
-
Oct 13th, 2000, 08:53 PM
#7
Addicted Member
sourry about the excessive underlining! i fixed it now ;D
To understand recursion, one must first understand the concept of recursion.
-
Oct 13th, 2000, 09:16 PM
#8
Hyperactive Member
NEver made an adventure...and probably never will
But with the support VB gives you for Classes and the forthcoming additional OO tools in VB7, I would use a customised linked list for each room.
Each room object can contain a collection of direction objects (or simple UDT). Each direction object contains a link to another room object. Direction objects have two labels (depending on which direction you are looking from) and may be enabled or disabled in each direction.
You would have to read in all of the serialised rooms and directions, but you will end up with a far easier way of dealing with events that can happen in rooms, objects/creatures that are present and other things that may change (such as night/day or weather conditions).
Each room object (and direction object for that matter) can implement an interface which accounts for any environmental changes that take place.
As I said, I've never made one so I cannot prove the worth of my suggestion. In OO terms though the theory is sound.
Regards
-
Oct 14th, 2000, 06:46 AM
#9
Thread Starter
Addicted Member
I said it was the EASIEST way, not the best, try reading my posts before replying to them. and its is a movement system for a MUD really, not a text adventure..
-
Oct 14th, 2000, 12:57 PM
#10
Member
Erm ... I did read it, and I didn't say it wasn't the easiest way, either. I was simply suggesting another idea, nearly as easy but more versatile. ::shrugs::
-
Oct 14th, 2000, 03:20 PM
#11
Hyperactive Member
-
Oct 14th, 2000, 05:19 PM
#12
Thread Starter
Addicted Member
Ok, I guess I reacted badly, it comes from answering emails at 6:30am when you cant sleep. I apologise as well for being bad tempered when there was no need. If you wanna do something for international relations(Theres me assuming your all american again ), you could take a look at my full app. A shortened(Little content) version is sat at http://www.enkidu.cx. A website is forthcoming, when I can be arsed. Considering this is the first full VB app Ive written, Id appreciate any comments on wether it even comes close to what you would consider sane. I've been told lots of times before that arrays are bad, but I like em dammit, and Im perfectly happy working with them, so, no array comments please :0
-
Oct 14th, 2000, 11:48 PM
#13
Hyperactive Member
I'm a Kiwi
I for one am not American. I'm Kiwi (in case that is meaningless to you it means I am from New Zealand).
Where is .cx?
Regards
-
Oct 15th, 2000, 04:27 AM
#14
Thread Starter
Addicted Member
.cx is christmas island, but Im in the UK, I just got the domain cheap
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|