Thread: MUD help...

  1. #1
    ------------
    Join Date
    Jun 2005
    Posts
    79

    MUD help...

    Ok, i am kind of new to c++ but decided to start a project that i can keep adding what i learn to. and since i started learning c++ so I could create a MUD i decided to do that. I was woundering how i would go about creating rooms, and with a (planned) overhead map (like using symbols to represent the diffrent rooms) like this:

    Planet: Earth
    ~~~~~~~~~~~~~~
    ~~~~^^^~~~~~~~
    ~~~~^^^^~~~~~~
    ~~~~~^^^~~~~~~
    ~~~~~^^^^^^~~~~
    coordinates: 41 x 42

    ^something like that, exept i will be planning on making it more elaborate (and eventualy adding colors). The map part can wait since im new and all (dont want to get into something i cant handle...) but i want to be able to at least make the rooms and cant find a tutorial for it anywere or know how to do it (arrays?)
    any help would be appreciated (BTW im not trying to get anyone to code anything for me, just need to know how i would go about coding it...)
    CAUTION: Newbie at programming!
    -------------------------------------------------
    Thanks everyone who helped me with all the questions, and utter lost-ness i happen to have... it is VERY VERY much appreciated

  2. #2
    Registered User MathFan's Avatar
    Join Date
    Apr 2002
    Posts
    190
    (arrays?)
    Mhm... That's a good way of doing it.
    Both terrain and your rooms can be coded with arrays. You are probably going to need a two-dimensional array. Each of the values in this array should represent an object in the game. To print the map/room on the screen you will have to cycle through the array and print each of the objects using cout or something.
    The OS requirements were Windows Vista Ultimate or better, so we used Linux.

  3. #3
    ------------
    Join Date
    Jun 2005
    Posts
    79
    hhmmm... i guess that makes sense (kind of...), im not 100% sure of what i would be doing but i'll read up on arrays until i get it thanks for the help (i havent gotten to arrays yet, but when trying to make a tic tac toe game i learned that using arrays to draw the board would be easiest so i kind of figured that this would be close to the same thing...)
    CAUTION: Newbie at programming!
    -------------------------------------------------
    Thanks everyone who helped me with all the questions, and utter lost-ness i happen to have... it is VERY VERY much appreciated

  4. #4
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    I would suggest an "area class" with an instance for each room/area, with information about the size of the room/area, perhaps stored in an array inside the class, and other information, like other players in the area, creatures, objects, etc.
    Away.

  5. #5
    Registered User
    Join Date
    Jul 2005
    Posts
    3
    Instead of using arrays (as that would be TOTALLY destructive to ones thought processes :P) take it based on direction. What I mean is this:
    Code:
          [1]---[3]
           |
          [2]
    Say those are rooms 1, 2 and 3. Basically you would build a class to hold the room data and you would link the rooms together by showing which rooms link in which direction.

    Code:
    class Room
    {
      private:
      int north;
      int south;
      int west;
      int east;
      int id;
    
      public:
      // set and get methods etc
    };
    Then basically you would link them like this using room 1 for our example.
    id = 1
    east = 3
    south = 2
    north = 0
    west = 0

    So basically if the direction is 0 then there is no room connecting to that particular exit out of the room. But if it's a non zero number that is the number of the room it connects to.

    Once you kind of grasp the idea of this you can throw the multi-dimensional array nightmare out the window. You can make this class more functional by adding more to it say like an up and a down, or a northeast anything like that.

    Hopefully that helps you a bit even if its just seeing another idea.

  6. #6
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    As a variant on the above mentioned example, you could also have pointers inside each class and have them point to the next room.
    Last edited by Frobozz; 07-11-2005 at 04:38 PM.

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Bubba and I had a big debate about these methods in this forum a while back. I'm sure you can find it if you look hard enough.


    Quzah.
    Hope is the first step on the road to disappointment.

  8. #8
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Searching quzah and bubba didnt work, but visa versa it did:
    http://cboard.cprogramming.com/showthread.php?t=62844

    Nice thread, that leads to another longer thread, that I'll have to read later.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My Mud
    By mrpickle in forum Game Programming
    Replies: 8
    Last Post: 01-07-2004, 07:32 AM
  2. MUD.. telnet problems.
    By dizolve in forum Game Programming
    Replies: 0
    Last Post: 10-13-2001, 02:06 PM
  3. MUD Programming: Combat
    By dizolve in forum C++ Programming
    Replies: 5
    Last Post: 10-12-2001, 10:14 AM