Results 1 to 14 of 14

Thread: Beginners Mapping System.

  1. #1

    Thread Starter
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147

    Talking

    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.

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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."

  3. #3

    Thread Starter
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147
    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

  4. #4
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185
    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.

  5. #5
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    Seems like DarkMoose found the way to underline! lol
    Sanity is a full time job

    Puh das war harter Stoff!

  6. #6
    Member
    Join Date
    Aug 2000
    Location
    USA
    Posts
    32
    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.
    -Koralt

  7. #7
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185
    sourry about the excessive underlining! i fixed it now ;D
    To understand recursion, one must first understand the concept of recursion.

  8. #8
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    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
    Paul Lewis

  9. #9

    Thread Starter
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147
    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..

  10. #10
    Member
    Join Date
    Aug 2000
    Location
    USA
    Posts
    32
    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::
    -Koralt

  11. #11
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    excuses excuses...

    tonyenkiducx, I was replying to Koralt who mentioned text adventure

    Your posts didn't really say what the system it was for so of course I assumed it was for what Koralt thought

    But if I were to critique your original post, I would need to disagree with your idea of easy. I understand that you thought of using multidimensional arrays and no UDT's for ease of use, but by ignoring UDT's you make your job harder.

    Personally, I find that beginners learn UDT's ultra fast whent hey have a good example to work from. The next step from UDT is really a Class but I would admitt that writing good classes is beyond most beginners.

    Finally, Koralt makes a good point about directions and relative room sizes so I guess a MUD is by definition a 2-D grid of same sized rooms? Does MUD=Multi User Dungeon or something?

    Anyhow, sorry for any insult you may have taken from my suggestion.

    Cheers
    Paul Lewis

  12. #12

    Thread Starter
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147

    Talking

    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

  13. #13
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    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
    Paul Lewis

  14. #14

    Thread Starter
    Addicted Member tonyenkiducx's Avatar
    Join Date
    Oct 2000
    Location
    London England
    Posts
    147
    .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
  •  



Click Here to Expand Forum to Full Width